IWMSCacheProxy::QueryCacheMissPolicy
Previous | Next |
IWMSCacheProxy::QueryCacheMissPolicy
The server calls the QueryCacheMissPolicy method to query the cache plug-in for a cache-miss policy.
Syntax
HRESULT QueryCacheMissPolicy( BSTR bstrOriginUrl , IWMSContext* pUserContext , IWMSCommandContext* pCommandContext , IWMSContext* pPresentationContext , IUnknown* pCachePluginContext , long lQueryType , IWMSCacheProxyCallback* pCallback , VARIANT varContext );
Parameters
bstrOriginUrl
[in] BSTR containing the origin URL.
pUserContext
[in] Pointer to an IWMSContext interface containing the user context.
pCommandContext
[in] Pointer to an IWMSCommandContext interface containing the command context.
pPresentationContext
[in] Pointer to an IWMSContext interface containing the presentation context.
pCachePluginContext
[in] Pointer to an IUnknown interface containing a cache plug-in context.
lQueryType
[in] Member of the WMS_CACHE_QUERY_TYPE_FLAGS enumeration type that indicates why the server called IWMSCacheProxy::QueryCache. This must be a bitwise OR of one or more of the following values.
Value | Description |
WMS_CACHE_QUERY_OPEN | A client using a downstream proxy requested content. |
WMS_CACHE_QUERY_GET_CONTENT_INFO | A downstream proxy requested information about content cached on the remote computer. |
WMS_CACHE_QUERY_CACHE_EVENT | A cache event notice is being sent upstream. If WMS_CACHE_QUERY_LOCAL_EVENT is set, the cache event was generated by the local computer. Otherwise, it was sent by a downstream proxy server. |
WMS_CACHE_QUERY_REVERSE_PROXY | A downstream server is configured to be a reverse proxy server. If a cache proxy plug-in supports reverse proxy, it can use this flag to determine whether it must map client requests to an upstream server farm. |
WMS_CACHE_QUERY_LOCAL_EVENT | The local server is generating an event to send upstream. |
pCallback
[in] Pointer to an IWMSCacheProxyCallback interface. The cache plug-in calls IWMSCacheProxyCallback::OnQueryCacheMissPolicy to respond to a call to QueryCacheMissPolicy.
varContext
[in] VARIANT containing a value defined by the server to identify which call to QueryCacheMissPolicy the plug-in is responding to when it calls IWMSCacheProxyCallback::OnQueryCacheMissPolicy. The plug-in must pass this value back unaltered.
Return Values
If the method succeeds, the plug-in must return S_OK. To report an error, the plug-in can return any HRESULT other than S_OK. If the plug-in uses the IWMSEventLog interface to log error information directly to the Windows Event Viewer, it is recommended that it return NS_E_PLUGIN_ERROR_REPORTED. Typically, the server attempts to make plug-in error information available to the server object model, the Windows Event Viewer, and the troubleshooting list in the details pane of the Windows Media Services MMC. However, if the plug-in uses the IWMSEventLog interface to send custom error information to the Windows Event Viewer, returning NS_E_PLUGIN_ERROR_REPORTED stops the server from also logging to the event viewer. For more information about retrieving plug-in error information, see Identifying Plug-in Errors.
Remarks
A proxy server must call QueryCache on the cache plug-in and receive a cache miss before it calls QueryCacheMissPolicy. A custom cache plug-in can use a WMS_CACHE_QUERY_TYPE_FLAGS enumeration value in the lQueryType parameter to direct implementation of a cache-miss policy.
Example Code
The following example illustrates one way that you can implement the QueryCacheMissPolicy method. How you choose to implement this method depends on the cache-miss policy that you want to create.
HRESULT STDMETHODCALLTYPE
CCachePlugin::QueryCacheMissPolicy( BSTR bstrOriginUrl, IWMSContext *pUserContext, IWMSCommandContext *pCommandContext, IWMSContext *pPresentationContext, IUnknown *pCachePluginContext, long QueryType, IWMSCacheProxyCallback *pCallback, VARIANT varContext ) { HRESULT hr = S_OK; // If the proxy is configured as a reverse proxy, // instruct the server to skip this plug-in. if( QueryType & WMS_CACHE_QUERY_REVERSE_PROXY ) { hr = pCallback->OnQueryCacheMissPolicy( S_OK, WMS_CACHE_QUERY_MISS_SKIP, NULL, NULL, NULL, varContext ); return( hr ); } // The downstream proxy has either raised an event or requested // information about content it has cached. Forward the request // to an upstream server. if( ( QueryType & WMS_CACHE_QUERY_CACHE_EVENT ) || ( QueryType & WMS_CACHE_QUERY_GET_CONTENT_INFO ) ) { hr = pCallback->OnQueryCacheMissPolicy( S_OK, WMS_CACHE_QUERY_MISS_FORWARD_REQUEST, NULL, NULL, NULL, varContext ); return( hr ); } // Call GetContentInformation(). hr = pCallback->GetContentInformation( bstrOriginUrl, pPresentationContext, this, (IWMSCacheProxyServerCallback *) this, varContext ); return( S_OK ); }
Requirements
Header: streamcache.h.
Library: WMSServerTypeLib.dll.
Platform: Windows Server 2003, Enterprise Edition; Windows Server 2003, Datacenter Edition; Windows Server 2008.
See Also
- IWMSCacheProxy Interface
- IWMSCacheProxy::QueryCache
- IWMSCacheProxyCallback Interface
- IWMSCommandContext Interface
- IWMSContext Interface
Previous | Next |