Udostępnij za pośrednictwem


ICacheManager::RefreshCache Method

For the latest version of Commerce Server 2007 Help, see the Microsoft Web site.

Use this method to force an immediate refresh of a data cache Dictionary object. This method is synchronous, not returning to the caller until the specified data cache is refreshed.

HRESULT ICacheManager::RefreshCache(
 BSTR bstrName
);
Sub RefreshCache(
  bstrName As String
)

Parameters

  • bstrName
    [C++]

    [in] A BSTR that contains the name of the cache to be retrieved.

    [Visual Basic]

    [in] 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.

    [Visual Basic]

    Not applicable.

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 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

[C++] 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.

Aa545696.alert_caution(en-US,CS.70).gifImportant Note:

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.

Example

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

Set oMyCache = myCacheManager.GetCache(strMyCacheName)

See Also

Other Resources

CacheManager Object