IHttpServer::FlushKernelCache (Método)
Vacía la caché del kernel para un identificador uniforme de recursos (URI) específico.
Sintaxis
virtual HRESULT FlushKernelCache(
IN PCWSTR pszUrl
) = 0;
Parámetros
pszUrl
[IN] Puntero a una cadena que contiene el URI que se va a vaciar.
Valor devuelto
Una clase HRESULT
. Entre los valores posibles se incluyen los que se indican en la tabla siguiente, entre otros.
Valor | Descripción |
---|---|
NO_ERROR | Indica que la operación se realizó correctamente. |
ERROR_INVALID_PARAMETER | Indica que se pasó un valor no válido en uno de los parámetros. |
ERROR_NOT_SUPPORTED | Indica que la operación no se admite en el contexto actual. |
Comentarios
Los desarrolladores pueden usar el FlushKernelCache
método para quitar un URI específico de la memoria caché del kernel.
Nota
El FlushKernelCache
método difiere del método IHttpResponse::D isableKernelCache , que deshabilita el almacenamiento en caché del kernel para el URI que está procesando la respuesta actual.
Ejemplo
En el ejemplo de código siguiente se muestra cómo crear un módulo HTTP que use el FlushKernelCache
método para vaciar la memoria caché del kernel para el URI /default.aspx.
#define _WINSOCKAPI_
#include <windows.h>
#include <sal.h>
#include <httpserv.h>
// Create a pointer for the global server interface.
IHttpServer * g_pHttpServer = NULL;
// Create the module class.
class MyHttpModule : public CHttpModule
{
public:
REQUEST_NOTIFICATION_STATUS
OnBeginRequest(
IN IHttpContext * pHttpContext,
IN IHttpEventProvider * pProvider
)
{
UNREFERENCED_PARAMETER( pProvider );
// Create an HRESULT to receive return values from methods.
HRESULT hr;
// Flush the kernel cache for the default.aspx page.
hr = g_pHttpServer->FlushKernelCache(L"/default.aspx");
// Test for an error.
if (FAILED(hr))
{
// Set the error status for the request.
pProvider->SetErrorStatus( hr );
// End additional processing.
return RQ_NOTIFICATION_FINISH_REQUEST;
}
// Return processing to the pipeline.
return RQ_NOTIFICATION_CONTINUE;
}
};
// Create the module's class factory.
class MyHttpModuleFactory : public IHttpModuleFactory
{
public:
HRESULT
GetHttpModule(
OUT CHttpModule ** ppModule,
IN IModuleAllocator * pAllocator
)
{
UNREFERENCED_PARAMETER( pAllocator );
// Create a new instance.
MyHttpModule * pModule = new MyHttpModule;
// Test for an error.
if (!pModule)
{
// Return an error if the factory cannot create the instance.
return HRESULT_FROM_WIN32( ERROR_NOT_ENOUGH_MEMORY );
}
else
{
// Return a pointer to the module.
*ppModule = pModule;
pModule = NULL;
// Return a success status.
return S_OK;
}
}
void Terminate()
{
// Remove the class from memory.
delete this;
}
};
// Create the module's exported registration function.
HRESULT
__stdcall
RegisterModule(
DWORD dwServerVersion,
IHttpModuleRegistrationInfo * pModuleInfo,
IHttpServer * pGlobalInfo
)
{
UNREFERENCED_PARAMETER( dwServerVersion );
// Store the pointer for the global server interface.
g_pHttpServer = pGlobalInfo;
// Set the request notifications and exit.
return pModuleInfo->SetRequestNotifications(
new MyHttpModuleFactory,
RQ_BEGIN_REQUEST,
0
);
}
El módulo debe exportar la función RegisterModule . Puede exportar esta función mediante la creación de un archivo de definición de módulo (.def) para el proyecto, o bien puede compilar el módulo mediante el /EXPORT:RegisterModule
modificador . Para obtener más información, vea Tutorial: Creación de un módulo HTTP de Request-Level mediante código nativo.
Opcionalmente, puede compilar el código mediante la __stdcall (/Gz)
convención de llamada en lugar de declarar explícitamente la convención de llamada para cada función.
Requisitos
Tipo | Descripción |
---|---|
Remoto | - IIS 7.0 en Windows Vista - IIS 7.5 en Windows 7 - IIS 8.0 en Windows 8 - IIS 10.0 en Windows 10 |
Servidor | - IIS 7.0 en Windows Server 2008 - IIS 7.5 en Windows Server 2008 R2 - IIS 8.0 en Windows Server 2012 - IIS 8.5 en Windows Server 2012 R2 - IIS 10.0 en Windows Server 2016 |
Producto | - IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0 - IIS Express 7.5, IIS Express 8.0, IIS Express 10.0 |
Encabezado | Httpserv.h |
Consulte también
IHttpServer (interfaz)
IHttpResponse::D isableKernelCache (Método)
IHttpResponse::GetCachePolicy (Método)
IHttpResponse::GetKernelCacheEnabled (Método)