BlobCache Sample: Generic Memory Caching
Demonstrates the use of the CBlobCache class from within an ATL Server application.
The BlobCache sample presents a Web page featuring a text input field that accepts numbers from 1 to 100. Entering a number and pressing the Lookup button causes the page to submit the value to the application DLL, which then uses the number as the key for a data item in an in-memory cache. If the cache contains an entry to the given number, the cached value corresponding to the key is returned; otherwise the number is used as an index into a data file containing strings. Regardless of how it was retrieved, the resulting value is displayed in the HTTP response, along with a message indicating whether the retrieved string had been cached.
This sample demonstrates:
Using ATL Server's CBlobCache class to cache generic blocks of memory.
Caching server-side data to improve response times.
This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes no liability for incidental or consequential damages should the sample code be used for purposes other than as intended.
Building and Running the Sample
To build and run this sample
Open the solution file, BlobCache.sln, in the Visual Studio development environment.
Build the solution. This will also deploy the solution to the local Web server.
Use a Web browser to view http://localhost/blobcache/blobcache.srf.
Enter a numeric value between 1 and 100 and click the Lookup button. See how varying or repeating requests for items affects the cache statistics displayed on the page.
CBlobCache | CBlobCache::Initialize | CBlobCache::QueryInterface | CBlobCache::Uninitialize | CHttpRequest::GetPhysicalPath | IMemoryCache | IMemoryCache::Add | IMemoryCache::Flush | IMemoryCache::GetData | IMemoryCache::LookupEntry | IMemoryCache::ReleaseEntry | IMemoryCacheClient | IMemoryCacheClient::Free | IMemoryCacheControl | IMemoryCacheControl::GetMaxAllowedEntries | IMemoryCacheControl::ResetCache | IMemoryCacheControl::SetMaxAllowedEntries | IMemoryCacheStats | IMemoryCacheStats::ClearStats | IMemoryCacheStats::GetCurrentEntryCount | IMemoryCacheStats::GetHitCount | IMemoryCacheStats::GetMaxEntryCount | IMemoryCacheStats::GetMissCount