ICacheManager::GetCache Method [C++]

Use this method to retrieve either the Dictionary or LRUCache object for the specified cache name.

Definition

[C++]

HRESULT ICacheManager::GetCache(BSTRbstrName,
 IDispatch**ppdict);

[Visual Basic]

Function GetCache(bstrName As String) As IDispatch

Parameters

  • bstrName[C++]
    [in] A BSTR that contains the name of the cache to be retrieved.
  • bstrName[Visual Basic]
    A String that contains the name of the cache to be retrieved.
  • ppdict[C++]
    [out,retval] A pointer used to return the IDispatch interface of the data cache Dictionary object.

Return Values

[C++] This method returns an HRESULT indicating whether it completed successfully. See the Error Values section for more details.

[Visual Basic] If this method completes successfully, it returns a reference to the data cache Dictionary object.

Error Values

[C++] This method returns S_OK (0x00000000) to indicate success and standard COM HRESULT error values to indicate failure. For more information about standard COM errors, see Standard COM Errors. Additional information may be available using the global Err object, which can be accessed using the API function GetErrorInfo. In particular, the GetDescription method of the IErrorInfo interface may return a text description of the error.

[Visual Basic] This method sets the Number property of the global Err object to S_OK (&H00000000) to indicate success and to standard COM error values to indicate failure. For more information about standard COM errors, see Standard COM Errors. Additional information may be available using the global Err object. In particular, the Description property may contain a text description of the error.

Remarks

This method is designed to be lightweight and fast. It is commonly called several times on any given ASP page.

The first time the GetCache method or the RefreshCache method is called, the data cache object is created and the configured CacheLoader component is invoked to populate it with data. Subsequent calls to the GetCache method may return the same cache object or a new cache object that is created when the cache is refreshed.

If the first call to the GetCache method for a particular cache results in a failed refresh, then the CacheManager object will not immediately retry a refresh when more GetCache method calls are made for the same cache. This is to avoid recurring timeouts that might bring down a system, for example if a database connection becomes temporarily unavailable. In this failure scenario, subsequent calls to the GetCache method will return an error indicating that the cache load failed and will not be retried until the refresh interval has elapsed or until the RefreshCache method is explicitly called.

After a cache has successfully been created, if a subsequent refresh of the cache fails, then the existing cache object is returned until a later refresh succeeds. The CacheManager object provides high availability to cache data at the expense of ensuring the cached data is up to date.

Ee824783.important(en-US,CS.20).gifImportant

  • When CacheManager is first instantiated in a Web application (normally when the first request to the application is received), it starts a background thread that is responsible for the automatic refreshing of caches. The security context of this thread is inherited from the ASP or ASP.NET worker thread at the time it is first created.

    Therefore, caution should be used if you deploy CacheManager in a site that is configured to impersonate users. Care should be used to ensure that the security context of the creating thread is a well-defined context such as the anonymous IIS process account.

[Visual Basic]

Example

'oMyCache is an object
'strMyCacheName is a String containing the name of an existing cache.

Set oMyCache = myCacheManager.GetCache(strMyCacheName)

See Also

[C++]CacheManager Object

[Visual Basic]CacheManager Object

Copyright © 2005 Microsoft Corporation.
All rights reserved.