예제 #1
0
 internal void UpdateUsage(DateTime utcNow, CacheUsage usage)
 {
     // update, but not more frequently than once per second.
     if (InUsage() && _utcLastUpdateUsage < utcNow - CacheUsage.CORRELATED_REQUEST_TIMEOUT)
     {
         _utcLastUpdateUsage = utcNow;
         usage.Update(this);
         if (_fields != null && _fields._dependencies != null)
         {
             foreach (ChangeMonitor monitor in _fields._dependencies)
             {
                 MemoryCacheEntryChangeMonitor m = monitor as MemoryCacheEntryChangeMonitor;
                 if (m == null)
                 {
                     continue;
                 }
                 foreach (MemoryCacheEntry e in m.Dependencies)
                 {
                     MemoryCacheStore store = e._fields._cache.GetStore(e);
                     e.UpdateUsage(utcNow, store.Usage);
                 }
             }
         }
     }
 }
예제 #2
0
 internal void RemoveDependent(MemoryCacheEntryChangeMonitor dependent)
 {
     lock (this) {
         if (_fields._dependents != null)
         {
             _fields._dependents.Remove(dependent);
         }
     }
 }
예제 #3
0
        internal void AddDependent(MemoryCache cache, MemoryCacheEntryChangeMonitor dependent)
        {
            lock (this)
            {
                if (State > EntryState.AddedToCache)
                {
                    return;
                }

                _fields ??= new SeldomUsedFields();
                _fields._cache ??= cache;
                _fields._dependents ??= new Dictionary <MemoryCacheEntryChangeMonitor, MemoryCacheEntryChangeMonitor>();
                _fields._dependents[dependent] = dependent;
            }
        }
 internal void AddDependent(MemoryCache cache, MemoryCacheEntryChangeMonitor dependent)
 {
     lock (this)
     {
         if (this.State <= EntryState.AddedToCache)
         {
             if (this._fields == null)
             {
                 this._fields = new SeldomUsedFields();
             }
             if (this._fields._cache == null)
             {
                 this._fields._cache = cache;
             }
             if (this._fields._dependents == null)
             {
                 this._fields._dependents = new Dictionary<MemoryCacheEntryChangeMonitor, MemoryCacheEntryChangeMonitor>();
             }
             this._fields._dependents[dependent] = dependent;
         }
     }
 }
예제 #5
0
 internal void AddDependent(MemoryCache cache, MemoryCacheEntryChangeMonitor dependent)
 {
     lock (this)
     {
         if (this.State <= EntryState.AddedToCache)
         {
             if (this._fields == null)
             {
                 this._fields = new SeldomUsedFields();
             }
             if (this._fields._cache == null)
             {
                 this._fields._cache = cache;
             }
             if (this._fields._dependents == null)
             {
                 this._fields._dependents = new Dictionary <MemoryCacheEntryChangeMonitor, MemoryCacheEntryChangeMonitor>();
             }
             this._fields._dependents[dependent] = dependent;
         }
     }
 }
예제 #6
0
 internal void UpdateUsage(DateTime utcNow, CacheUsage usage)
 {
     if (this.InUsage() && (this._utcLastUpdateUsage < (utcNow - CacheUsage.CORRELATED_REQUEST_TIMEOUT)))
     {
         this._utcLastUpdateUsage = utcNow;
         usage.Update(this);
         if ((this._fields != null) && (this._fields._dependencies != null))
         {
             foreach (ChangeMonitor monitor in this._fields._dependencies)
             {
                 MemoryCacheEntryChangeMonitor monitor2 = monitor as MemoryCacheEntryChangeMonitor;
                 if (monitor2 != null)
                 {
                     foreach (MemoryCacheEntry entry in monitor2.Dependencies)
                     {
                         MemoryCacheStore store = entry._fields._cache.GetStore(entry);
                         entry.UpdateUsage(utcNow, store.Usage);
                     }
                 }
             }
         }
     }
 }
 internal void RemoveDependent(MemoryCacheEntryChangeMonitor dependent) {
     lock (this) {
         if (_fields._dependents != null) {
             _fields._dependents.Remove(dependent);
         }
     }
 }