| title | IHttpCacheSpecificData::GetCacheKey Method |
|---|---|
| description | Describes the IHttpCacheSpecificData::GetCacheKey method and details its syntax, parameters, return value, remarks, code example, and requirements. |
| ms.date | 10/07/2016 |
| ms.assetid | 3e91916c-8c29-70fa-7985-acb0b2beccdc |
Returns the cache key associated with the cached data.
virtual IHttpCacheKey* GetCacheKey(
VOID
) const = 0; This method takes no parameters.
An IHttpCacheKey pointer.
The behavior of the GetCacheKey method is implementation specific. You should use the following information as a guideline, but it may not be correct in all scenarios:
-
Classes that implement the IHttpFileInfo interface usually return a downcasted IFileKey pointer.
-
Classes that implement the IHttpTokenEntry interface usually return a downcasted IHttpTokenKey pointer.
-
Classes that implement both the IHttpCacheSpecificData and IHttpUrlInfo interfaces usually return a downcasted IUriKey pointer.
Caution
Before you perform any downcast operation, always verify that the cast is valid to guarantee correct program behavior.
Note
Consider using the dynamic_cast operator whenever possible when you perform a downcast operation.
IHttpCacheSpecificData implementers are responsible for memory management with this data; therefore, IHttpCacheSpecificData implementers that use dynamic memory allocation must release or call delete on the IHttpCacheKey pointer when it is no longer needed.
IHttpCacheSpecificData implementers are responsible for memory management with this data; therefore, IHttpCacheSpecificData clients must not release or call delete on the returned IHttpCacheKey pointer when this data is no longer needed.
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 IHttpCacheKey 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-cppIHttpCacheSpecificData#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.
<cacheProvider>
<cacheSpecificData
flushed="false">
<uriKey
siteId="1"
siteName="Default Web Site"
url="/DEFAULT.HTM"
cacheName="URI"
hash="59390334"
isEqual="true"
isPrefix="true"/>
</cacheSpecificData>
</cacheProvider>
<cacheProvider>
<fileInfo
changed="false"
attributes="32"
eTag=""5e5e714ef4dc61:0""
buffer="false"
handle="valid"
path="C:\INETPUB\WWWROOT\DEFAULT.HTM"
cacheAllowed="true"
secondsToLive="-1"
lastModifiedString="Tue, 21 Mar 2006 17:45:56 GMT"
lastModifiedTime="valid"
size="92"
vrPath="C:\inetpub\wwwroot"
vrToken="NULL"
flushed="false">
<contextContainer>
<storedContext/>
</contextContainer>
<fileKey path="D:\INETPUB\WWWROOT\DEFAULT.HTM"
cacheName="FILE"
hash="206817538"
isEqual="true"
isPrefix="true"/>
</fileInfo>
</cacheProvider>
<cacheProvider>
<tokenEntry
impersonationToken="valid"
primaryToken="valid"
sid="valid"
flushed="false">
<tokenKey
userName="IUSR"
passwordHash="1234567890"
logon="3"
cacheName="TOKEN"
hash="0"
isEqual="true"
isPrefix="false"/>
</tokenEntry>
</cacheProvider>
<cacheProvider>
<cacheSpecificData
flushed="false">
<uriKey
siteId="1"
siteName="Default Web Site"
url="/"
cacheName="URI"
hash="46"
isEqual="true"
isPrefix="true"/>
</cacheSpecificData>
</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 |