/// <summary>
        /// Returns the encoded <see cref="CountingMemoryCache{K, V}"/>.
        /// </summary>
        public static CountingMemoryCache <ICacheKey, IPooledByteBuffer> Get(
            ISupplier <MemoryCacheParams> encodedMemoryCacheParamsSupplier,
            IMemoryTrimmableRegistry memoryTrimmableRegistry,
            PlatformBitmapFactory platformBitmapFactory)
        {
            IValueDescriptor <IPooledByteBuffer> valueDescriptor =
                new ValueDescriptorImpl <IPooledByteBuffer>(
                    (value) =>
            {
                return(value.Size);
            });

            ICacheTrimStrategy trimStrategy = new NativeMemoryCacheTrimStrategy();

            CountingMemoryCache <ICacheKey, IPooledByteBuffer> countingCache =
                new CountingMemoryCache <ICacheKey, IPooledByteBuffer>(
                    valueDescriptor,
                    trimStrategy,
                    encodedMemoryCacheParamsSupplier,
                    platformBitmapFactory,
                    false);

            memoryTrimmableRegistry.RegisterMemoryTrimmable(countingCache);

            return(countingCache);
        }
Beispiel #2
0
        /// <summary>
        /// Instantiates the bitmap counting memory cache.
        /// </summary>
        public static CountingMemoryCache <ICacheKey, CloseableImage> Get(
            ISupplier <MemoryCacheParams> bitmapMemoryCacheParamsSupplier,
            IMemoryTrimmableRegistry memoryTrimmableRegistry,
            PlatformBitmapFactory platformBitmapFactory,
            bool isExternalCreatedBitmapLogEnabled)
        {
            IValueDescriptor <CloseableImage> valueDescriptor =
                new ValueDescriptorImpl <CloseableImage>(
                    (value) =>
            {
                return(value.SizeInBytes);
            });

            ICacheTrimStrategy trimStrategy = new BitmapMemoryCacheTrimStrategy();

            CountingMemoryCache <ICacheKey, CloseableImage> countingCache =
                new CountingMemoryCache <ICacheKey, CloseableImage>(
                    valueDescriptor,
                    trimStrategy,
                    bitmapMemoryCacheParamsSupplier,
                    platformBitmapFactory,
                    isExternalCreatedBitmapLogEnabled);

            memoryTrimmableRegistry.RegisterMemoryTrimmable(countingCache);

            return(countingCache);
        }