internal override void TouchAfterUnlocked(CacheRecord record, bool recordIsNew) { if (recordIsNew) { this.NotifyObservers(record.GetFuture(), true); } }
private void Clean(bool purge) { int num = 0; long num2 = this.memoryUsed; List <CacheRecord> list = new List <CacheRecord>(); Monitor.Enter(this); try { while ((purge && this.lruQueue.Count > 0) || (this.memoryUsed > SizeSensitiveCache.paramCacheMaxSize && ((SizeSensitiveCache.oneEntryAtATime && this.lruQueue.Count > 0) || (!SizeSensitiveCache.oneEntryAtATime && this.lruQueue.Count > 1)))) { CacheRecord value = this.lruQueue.First.Value; num++; list.Add(value); this.Remove(value, CacheBase.RemoveExpectation.Present); this.spillCount++; } } finally { Monitor.Exit(this); } foreach (CacheRecord current in list) { this.NotifyObservers(current.GetFuture(), false); } D.Sayf(10, "SizeSensitive Cleaner: removed {0} objects; from {1} to {2} MB", new object[] { num, num2 >> 20, this.memoryUsed >> 20 }); }
internal override void Touch(CacheRecord record, bool recordIsNew) { if (recordIsNew) { this.clockQueue.AddLast(record); } ((ClockCacheRecord)record).touched = true; }
internal override void Touch(CacheRecord record, bool recordIsNew) { if (!recordIsNew) { this.lruQueue.Remove(record); } this.UpdateSizeForRecord((SizedCacheRecord)record); this.lruQueue.AddLast(record); }
internal virtual void Remove(CacheRecord record, CacheBase.RemoveExpectation removeExpectation) { Monitor.Enter(this); try { bool flag = this.cache.Remove(record.GetFuture()); D.Assert(removeExpectation == CacheBase.RemoveExpectation.Unknown || removeExpectation == CacheBase.RemoveExpectation.Present == flag, "Remove didn't meet expectations. That could suggest a mutating hash."); this.resourceCounter.crement(-1); record.DropReference(); } finally { Monitor.Exit(this); } }
internal void Evict(IFuture future) { Monitor.Enter(this); try { bool flag = cache.ContainsKey(future); if (flag) { CacheRecord record = cache[future]; Remove(record, RemoveExpectation.Unknown); } } finally { Monitor.Exit(this); } }
internal override void Remove(CacheRecord record, CacheBase.RemoveExpectation removeExpectation) { base.Remove(record, removeExpectation); }
internal abstract void Touch(CacheRecord record, bool recordIsNew);
internal override void Remove(CacheRecord record, RemoveExpectation removeExpectation) { base.Remove(record, removeExpectation); }
internal override void Remove(CacheRecord record, CacheBase.RemoveExpectation removeExpectation) { this.memoryUsed -= ((SizedCacheRecord)record).memoryCharge; this.lruQueue.Remove(record); base.Remove(record, removeExpectation); }
internal virtual void TouchAfterUnlocked(CacheRecord record, bool recordIsNew) { }