title | description | ms.date | ms.assetid |
---|---|---|---|
ICacheProvider::GetCacheRecord Method |
Describes the ICacheProvider::GetCacheRecord method and provides the method's syntax, return value, remarks, examples, and requirements. |
10/07/2016 |
212ddfc3-7d3c-eca9-efa5-a87f340dcd69 |
Returns the cache record for the cache provider.
virtual IHttpCacheSpecificData* GetCacheRecord(
VOID
) const = 0;
This method takes no parameters.
A pointer to an IHttpCacheSpecificData interface.
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 IHttpCacheSpecificData
pointer by calling the GetCacheRecord
method on the ICacheProvider
pointer.
ICacheProvider implementers declare a private``IHttpCacheSpecificData
pointer as member data. When constructors of these implementers are called, this member data is assigned to an IHttpCacheSpecificData
pointer. Before calling the SetCacheRecord method
, the caller is responsible for first calling the IHttpCacheSpecificData::ReferenceCacheData method on the IHttpCacheSpecificData
pointer; SetCacheRecord
implementers then assign the private
variable to this IHttpCacheSpecificData
pointer.
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 take ownership of the IHttpCacheSpecificData
pointer. Before calling SetCacheRecord
, first call IHttpCacheSpecificData::ReferenceCacheData
on the pointer so that this pointer has one owner. Callers of GetCacheRecord
do not take ownership of the returned IHttpCacheSpecificData
pointer.
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 lists sample 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 IHttpCacheSpecificData
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#4]
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 a new event to the application log of the Event Viewer, where the Data box contains XML similar to the following.
<cacheProvider>
<fileInfo />
</cacheProvider>
<cacheProvider>
<tokenEntry />
</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 |