GetCache Method

Returns the cache client, an instance of the DataCache object.

Namespace:  Microsoft.ApplicationServer.Caching
Assembly:  Microsoft.ApplicationServer.Caching.Client (in Microsoft.ApplicationServer.Caching.Client.dll)


Public Function GetCache ( _
    cacheName As String _
) As DataCache
Dim instance As DataCacheFactory
Dim cacheName As String
Dim returnValue As DataCache

returnValue = instance.GetCache(cacheName)
public DataCache GetCache(
    string cacheName
DataCache^ GetCache(
    String^ cacheName
member GetCache : 
        cacheName:string -> DataCache 
public function GetCache(
    cacheName : String
) : DataCache


Return Value

Type: Microsoft.ApplicationServer.Caching. . :: . .DataCache
The cache client, an instance of the DataCache object.


Before working with the cache, you must instantiate the DataCacheFactory class.

The cache client returned by this method can be configured programmatically, or by the application configuration file. When a DataCacheFactoryConfiguration parameter is passed to the DataCacheFactory class constructor, those configuration settings are used for all cache clients obtained from that DataCacheFactory object. Configuration parameters passed to the constructor override settings specified in the application configuration file. If no parameters are provided to the DataCacheFactory class constructor, the cache client configuration parameters come from the application configuration file.


Before working with a named cache, you must first create it. In Microsoft AppFabric 1.1 for Windows Server Caching, you create the cache with the New-Cache Windows PowerShell. You can also use the Get-Cache command with no parameters to get a list of caches on an on-premises cache cluster. Cache names are case sensitive.


In Windows Azure Caching, you configure the named caches as part of the cloud service configuration.


Windows Azure Shared Caching supports only the default cache. However, you still need to create a namespace for each cache.

See Also


DataCacheFactory Class

Microsoft.ApplicationServer.Caching Namespace