Skip to main content
ATL Server Library Reference 
CBlobCache Class 

This class provides functionality for caching arbitrarily sized data blocks in memory.

template <
   class MonitorClass,
   class StatClass  = CStdStatClass,
   class SyncObj    = CComCriticalSection,
   class FlushClass = COldFlusher,
   class CullClass  = CExpireCuller
class CBlobCache :
   public CMemoryCache< void* , StatClass, FlushClass, CFixedStringKey,
         CStringElementTraits< CFixedStringKey >, SyncObj, CullClass >,
   public IMemoryCache,
   public IMemoryCacheControl,
   public IMemoryCacheStats,
   public IWorkerThreadClient



The class to be used for periodic cache maintenance. Normally, this will be CWorkerThread. If no cache maintenance is desired, use CNoWorkerThread.


The class used to collect and expose statistics related to the use of the cache, such as effectiveness and memory used. This must conform to the cache statistics archetype. By default the CStdStatClass is used, which provides standard cache statistics. If no statistics are desired, use CNoStatClass.


The class to be used for thread synchronization. The default value of CComCriticalSection is suitable for most situations, but the CComFakeCriticalSection class can be used to avoid thread synchronization overhead in single-threaded environments.


The class used to determine whether, and in what order, items should be removed from the cache using the number and sequence of accesses as the basis for making the decision. This must conform to the cache flusher archetype.

This class is used to remove items from the cache to comply with the size and memory constraints specified through the IMemoryCacheControl interface. Use the CNoFlusher class if no automatic flushing is to be performed.


The class used to determine to determine whether, and in what order, items should be removed from the cache using time-based criteria. Must conform to the cache culler archetype. Use the CNoExpireCuller class if no culling is to be performed.

CBlobCache provides support for caching items in memory. Data can be added to the cache with the Add method and removed with the RemoveEntry method. The number of currently stored items can be retrieved with the GetCurrentEntryCount method.

CBlobCache derives from CMemoryCache, which provides most of the class's functionality. CBlobCache adds to this by periodically removing old, unused entries from the cache. If MonitorClass is set to CWorkerThread, the cache will be flushed with a frequency determined by ATL_BLOB_CACHE_TIMEOUT.

Cache statistics can be gathered using the members exposed by the IMemoryCacheStats interface, such as GetHitCount and GetMissCount.

See the BlobCache sample for a demonstration of how this class can be used in an ATL Server application.

Header: atlcache.h