Chapter 12: Caching


ATL SERVER PROVIDES EXTENSIVE and versatile caching support that you can use from within ATL Server Web applications and Web services, or independently in applications unrelated to the Web. Caching is a useful way to improve the performance of your application. By caching data that would be prohibitively expensive to retrieve or compute on every request, you can significantly enhance the performance of a Web application or Web service.

In this chapter, we examine the different types of caches offered by the ATL Server framework. We also discuss how to customize the caches for specific data types and how to override default values for timeouts.

Types of Caches

ATL Server offers several different types of caches, each with its own intended purpose, customization, and benefits. You ll cover these cache types in detail in this section.

CMemoryCacheBase

CMemoryCacheBase is the base class for CMemoryCache , CStencilCache , and CFileCache . This class provides the basic functionality of caching data items in memory and implements the basic flushing and culling capabilities of the derived caches.

CMemoryCache

This cache stores cache data items in memory. When you add items to this cache, it s possible to pass in an HINSTANCE to the DLL in which the data lives. The cache will increment the reference count of that DLL (i.e., it will add-ref it) to ensure the DLL isn t unloaded while the data is still active in the cache. To use this functionality, you need to pass in a valid IServiceProvider to the Initialize function of the cache. That IServiceProvider must have IDllCache as one of its services.

CBlobCache

This cache stores cache data items in memory. This class inherits from CMemoryCache . When you add items to this cache, the cache will ensure that adding the entry won t cause the cache to exceed the limits set for cache memory allocation size and maximum entry count.

CDllCache

This cache caches DLLs and deals with the loading and unloading of DLLs in the cache based on reference counts.

CStencilCache

This is a cache specific to ATL Server. It s unlikely users will use this class independently. You use CStencilCache to cache preprocessed stencils for request handler processing, thus saving you the cost of parsing the stencil on every request.

CFileCache

This cache keeps track of files. Even though this cache is derived from CMemoryCacheBase , the files aren t cached in memory ”only the filenames are cached. When a file cache entry expires or is removed from the cache for any reason, it s deleted from disk.

CDataSourceCache

This cache stores open database connection in memory. This cache is somewhat different from the other ATL Server caches in that it s very specific, very simple, and assumes synchronous access. That s why when you choose the Data source cache option in the ATL Server Project Wizard, the cache is added as a per-thread service.

All of the caches (with the exception of CDataSourceCache ) have flushing and culling capability. Flushing removes items from the cache based on criteria such as least recently used or least often used. Culling removes items from the cache based on data expiration and data lifetimes.




ATL Server. High Performance C++ on. NET
Observing the User Experience: A Practitioners Guide to User Research
ISBN: B006Z372QQ
EAN: 2147483647
Year: 2002
Pages: 181

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net