コード例 #1
0
        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);
                }
            }
        }
コード例 #2
0
        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);
                });
            }
        }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
        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);
                    });
                }
            }
        }
コード例 #5
0
 void IMemoryCacheManager.ReleaseCache(MemoryCache memoryCache)
 {
     if (memoryCache == null)
     {
         throw new ArgumentNullException("memoryCache");
     }
     lock (_lock) {
         if (_cacheInfos != null)
         {
             MemoryCacheInfo info = null;
             if (_cacheInfos.TryGetValue(memoryCache, out info))
             {
                 _cacheInfos.Remove(memoryCache);
             }
         }
     }
 }
コード例 #6
0
 void IMemoryCacheManager.UpdateCacheSize(long size, MemoryCache memoryCache)
 {
     if (memoryCache == null)
     {
         throw new ArgumentNullException("memoryCache");
     }
     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;
         }
         info.Size = size;
     }
 }
コード例 #7
0
 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);
     }
 }