/// <summary> /// Returns the instrumented <see cref="EncodedCountingMemoryCacheFactory"/>. /// </summary> public static IMemoryCache <ICacheKey, IPooledByteBuffer> Get( CountingMemoryCache <ICacheKey, IPooledByteBuffer> encodedCountingMemoryCache, IImageCacheStatsTracker imageCacheStatsTracker) { imageCacheStatsTracker.RegisterEncodedMemoryCache(encodedCountingMemoryCache); IMemoryCacheTracker memoryCacheTracker = new MemoryCacheTrackerImpl( () => { imageCacheStatsTracker.OnMemoryCacheHit(); }, () => { imageCacheStatsTracker.OnMemoryCacheMiss(); }, () => { imageCacheStatsTracker.OnMemoryCachePut(); }); return(new InstrumentedMemoryCache <ICacheKey, IPooledByteBuffer>( encodedCountingMemoryCache, memoryCacheTracker)); }
/// <summary> /// Gets the instrumented memory cache. /// </summary> public static IMemoryCache <ICacheKey, CloseableImage> Get( CountingMemoryCache <ICacheKey, CloseableImage> bitmapCountingMemoryCache, IImageCacheStatsTracker imageCacheStatsTracker) { imageCacheStatsTracker.RegisterBitmapMemoryCache(bitmapCountingMemoryCache); IMemoryCacheTracker memoryCacheTracker = new MemoryCacheTrackerImpl( () => { imageCacheStatsTracker.OnBitmapCacheHit(); }, () => { imageCacheStatsTracker.OnBitmapCacheMiss(); }, () => { imageCacheStatsTracker.OnBitmapCachePut(); }); return(new InstrumentedMemoryCache <ICacheKey, CloseableImage>( bitmapCountingMemoryCache, memoryCacheTracker)); }