void IMemoryCacheManager.ReleaseCache(MemoryCache memoryCache)
        {
            if (memoryCache == null)
            {
                throw new ArgumentNullException("memoryCache");
            }
            long sizeUpdate = 0L;

            lock (this._lock)
            {
                if (this._cacheInfos != null)
                {
                    MemoryCacheInfo info = null;
                    if (this._cacheInfos.TryGetValue(memoryCache, out info))
                    {
                        sizeUpdate = -info.Size;
                        this._cacheInfos.Remove(memoryCache);
                    }
                }
            }
            if (sizeUpdate != 0L)
            {
                ApplicationManager applicationManager = HostingEnvironment.GetApplicationManager();
                if (applicationManager != null)
                {
                    applicationManager.GetUpdatedTotalCacheSize(sizeUpdate);
                }
            }
        }
        void IMemoryCacheManager.UpdateCacheSize(long size, MemoryCache memoryCache)
        {
            if (memoryCache == null)
            {
                throw new ArgumentNullException("memoryCache");
            }
            long delta = 0;

            lock (_lock) {
                if (_cacheInfos == null)
                {
                    _cacheInfos = new Dictionary <MemoryCache, MemoryCacheInfo>();
                }
                MemoryCacheInfo info = null;
                if (!_cacheInfos.TryGetValue(memoryCache, out info))
                {
                    info       = new MemoryCacheInfo();
                    info.Cache = memoryCache;
                    _cacheInfos[memoryCache] = info;
                }
                delta     = size - info.Size;
                info.Size = size;
            }
            ApplicationManager appManager = HostingEnvironment.GetApplicationManager();

            if (appManager != null)
            {
                ExecutionContextUtil.RunInNullExecutionContext(delegate {
                    appManager.GetUpdatedTotalCacheSize(delta);
                });
            }
        }
        void IMemoryCacheManager.UpdateCacheSize(long size, MemoryCache memoryCache)
        {
            if (memoryCache == null)
            {
                throw new ArgumentNullException("memoryCache");
            }
            long sizeUpdate = 0L;

            lock (this._lock)
            {
                if (this._cacheInfos == null)
                {
                    this._cacheInfos = new Dictionary <MemoryCache, MemoryCacheInfo>();
                }
                MemoryCacheInfo info = null;
                if (!this._cacheInfos.TryGetValue(memoryCache, out info))
                {
                    info = new MemoryCacheInfo {
                        Cache = memoryCache
                    };
                    this._cacheInfos[memoryCache] = info;
                }
                sizeUpdate = size - info.Size;
                info.Size  = size;
            }
            ApplicationManager applicationManager = HostingEnvironment.GetApplicationManager();

            if (applicationManager != null)
            {
                applicationManager.GetUpdatedTotalCacheSize(sizeUpdate);
            }
        }
        void IMemoryCacheManager.ReleaseCache(MemoryCache memoryCache)
        {
            if (memoryCache == null)
            {
                throw new ArgumentNullException("memoryCache");
            }
            long delta = 0;

            lock (_lock) {
                if (_cacheInfos != null)
                {
                    MemoryCacheInfo info = null;
                    if (_cacheInfos.TryGetValue(memoryCache, out info))
                    {
                        delta = 0 - info.Size;
                        _cacheInfos.Remove(memoryCache);
                    }
                }
            }
            if (delta != 0)
            {
                ApplicationManager appManager = HostingEnvironment.GetApplicationManager();
                if (appManager != null)
                {
                    ExecutionContextUtil.RunInNullExecutionContext(delegate {
                        appManager.GetUpdatedTotalCacheSize(delta);
                    });
                }
            }
        }