title | description | ms.date | ms.assetid |
---|---|---|---|
ICacheProvider::GetCacheKey Method |
Describes the ICacheProvider::GetCacheKey method and provides the method's syntax, return value, remarks, notes for implementers, an example, and requirements. |
10/07/2016 |
557ae36c-12e4-cbda-4178-67c3620067c6 |
Returns the cache key for the cache provider.
virtual IHttpCacheKey* GetCacheKey(
VOID
) const = 0;
This method takes no parameters.
A pointer to an IHttpCacheKey for the cache provider.
CGlobalModule derived classes that register for GL_CACHE_OPERATION events receive an ICacheProvider pointer as a parameter on the CGlobalModule::OnGlobalCacheOperationvirtual
method. You can retrieve an IHttpCacheKey
pointer by calling the GetCacheKey
method on the ICacheProvider
pointer.
ICacheProvider
implementers are responsible for memory management with this data; therefore, ICacheProvider
implementers that use dynamic memory allocation must release or call delete
on the IHttpCacheKey
pointer when it is no longer needed.
The following table is a sample of one-to-one interface mappings that must be returned from the GetCacheKey
and GetCacheRecord methods from the same implementer of the ICacheProvider
interface.
GetCacheKey interface | GetCacheRecord interface |
---|---|
IFileKey | IHttpFileInfo |
IHttpTokenKey | IHttpTokenEntry |
IHttpCacheKey |
IHttpCacheSpecificData |
ICacheProvider
implementers are responsible for memory management with this data; therefore, ICacheProvider
clients must not release or call delete
on the returned IHttpCacheKey
pointer when this data is no longer needed.
In some cases, an IHttpCacheSpecificData
pointer returned from GetCacheRecord
may be downcast to a more specific interface to access extended behavior. Call the GetCacheKey
method to retrieve the IHttpCacheKey
pointer, and then call the IHttpCacheKey::GetCacheName method to retrieve the name of the cache. The following table is a sample of values returned from GetCacheName
and the corresponding interface to which the current IHttpCacheSpecificData
pointer may then be safely downcast, assuming an otherwise correct downcast procedure takes place. See IIS Caching Constants for constant values.
GetCacheName value | Interface |
---|---|
FILE | IHttpFileInfo |
TOKEN | IHttpTokenEntry |
Caution
Before performing any downcast operation, always verify that the cast is correct to guarantee correct program behavior.
Note
Consider using the dynamic_cast operator whenever possible when you perform a downcast operation.
The following code example demonstrates how to create a global module that listens for GL_CACHE_OPERATION
and GL_CACHE_CLEANUP events and then writes the ICacheProvider
information to the Event Viewer.
Caution
[!INCLUDEiisver] generates a large number of events in the Event Viewer. To avoid a log overflow error in a production environment, you should generally avoid writing cache information to the event log. For demonstration purposes, this code example writes an entry to the Event Viewer in debug mode only.
[!code-cppICacheProvider#2]
For more information on how to create and deploy a native DLL module, see Walkthrough: Creating a Request-Level HTTP Module By Using Native Code.
The above code writes new events to the application log of the Event Viewer, where the Data box contains XML similar to the following (depending on the IHttpCacheKey
type).
<cacheProvider>
<uriKey />
</cacheProvider>
<cacheProvider>
<tokenKey />
</cacheProvider>
<cacheProvider>
<fileKey />
</cacheProvider>
You can optionally compile the code by using the __stdcall (/Gz)
calling convention instead of explicitly declaring the calling convention for each function.
Type | Description |
---|---|
Client | - IIS 7.0 on [!INCLUDEwinvista] - IIS 7.5 on Windows 7 - IIS 8.0 on Windows 8 - IIS 10.0 on Windows 10 |
Server | - IIS 7.0 on [!INCLUDEwinsrv2008] - IIS 7.5 on Windows Server 2008 R2 - IIS 8.0 on Windows Server 2012 - IIS 8.5 on Windows Server 2012 R2 - IIS 10.0 on Windows Server 2016 |
Product | - IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0 - [!INCLUDEiisexp75], [!INCLUDEiisexp80], [!INCLUDEiisexp100] |
Header | Httpserv.h |