Share via


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)

Syntax

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

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

Parameters

Return Value

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

Remarks

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.

Note

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.

Warning

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

Note

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

See Also

Reference

DataCacheFactory Class

Microsoft.ApplicationServer.Caching Namespace