1 instantiation of CacheEntry
Microsoft.Extensions.Caching.Memory (1)
MemoryCache.cs (1)
104return new CacheEntry(key, this);
55 references to CacheEntry
Microsoft.Extensions.Caching.Memory (55)
CacheEntry.CacheEntryTokens.cs (6)
27internal void AttachTokens(CacheEntry cacheEntry) 48internal bool CheckForExpiredTokens(CacheEntry cacheEntry) 68internal void PropagateTokens(CacheEntry parentEntry) 105internal void InvokeEvictionCallbacks(CacheEntry cacheEntry) 109Task.Factory.StartNew(state => InvokeCallbacks((CacheEntry)state!), cacheEntry, 114private static void InvokeCallbacks(CacheEntry entry)
CacheEntry.cs (9)
18private static readonly AsyncLocal<CacheEntry?> _current = new AsyncLocal<CacheEntry?>(); 26private CacheEntry? _previous; // this field is not null only before the entry is added to the cache and tracking is enabled 47AsyncLocal<CacheEntry?> holder = _current; 54internal static CacheEntry? Current => _current.Value; 214CacheEntry? parent = _previous; 281var entry = (CacheEntry)state!; 291if ((_tokens == null || !_tokens.CanPropagateTokens()) && _absoluteExpirationTicks < 0 || _current.Value is not CacheEntry parent)
MemoryCache.cs (40)
107internal void SetEntry(CacheEntry entry) 138if (coherentState.TryGetValue(entry.Key, out CacheEntry? priorEntry)) 214if (coherentState.TryGetValue(key, out CacheEntry? tmp)) 216CacheEntry entry = tmp; 274if (coherentState.TryRemove(key, out CacheEntry? entry)) 296foreach (CacheEntry entry in oldState.GetAllValues()) 324internal void EntryExpired(CacheEntry entry) 421foreach (CacheEntry entry in coherentState.GetAllValues()) 438private bool UpdateCacheSizeExceedsCapacity(CacheEntry entry, CacheEntry? priorEntry, CoherentState coherentState) 533private void Compact(long removalSizeTarget, Func<CacheEntry, long> computeEntrySize, CoherentState coherentState) 535var entriesToRemove = new List<CacheEntry>(); 537var lowPriEntries = new List<(CacheEntry entry, DateTimeOffset lastAccessed)>(); 538var normalPriEntries = new List<(CacheEntry entry, DateTimeOffset lastAccessed)>(); 539var highPriEntries = new List<(CacheEntry entry, DateTimeOffset lastAccessed)>(); 544foreach (CacheEntry entry in coherentState.GetAllValues()) 576foreach (CacheEntry entry in entriesToRemove) 586static void ExpirePriorityBucket(ref long removedSize, long removalSizeTarget, Func<CacheEntry, long> computeEntrySize, List<CacheEntry> entriesToRemove, List<(CacheEntry Entry, DateTimeOffset LastAccessed)> priorityEntries) 600foreach ((CacheEntry entry, _) in priorityEntries) 672private readonly ConcurrentDictionary<string, CacheEntry> _stringEntries = new ConcurrentDictionary<string, CacheEntry>(StringKeyComparer.Instance); 673private readonly ConcurrentDictionary<object, CacheEntry> _nonStringEntries = new ConcurrentDictionary<object, CacheEntry>(); 676internal bool TryGetValue(object key, [NotNullWhen(true)] out CacheEntry? entry) 679internal bool TryRemove(object key, [NotNullWhen(true)] out CacheEntry? entry) 682internal bool TryAdd(object key, CacheEntry entry) 685internal bool TryUpdate(object key, CacheEntry entry, CacheEntry comparison) 688public IEnumerable<CacheEntry> GetAllValues() 694foreach (KeyValuePair<string, CacheEntry> entry in _stringEntries) 698foreach (KeyValuePair<object, CacheEntry> entry in _nonStringEntries) 706foreach (KeyValuePair<string, CacheEntry> pairs in _stringEntries) 710foreach (KeyValuePair<object, CacheEntry> pairs in _nonStringEntries) 716private ICollection<KeyValuePair<string, CacheEntry>> StringEntriesCollection => _stringEntries; 717private ICollection<KeyValuePair<object, CacheEntry>> NonStringEntriesCollection => _nonStringEntries; 723internal void RemoveEntry(CacheEntry entry, MemoryCacheOptions options) 727if (StringEntriesCollection.Remove(new KeyValuePair<string, CacheEntry>(s, entry))) 736else if (NonStringEntriesCollection.Remove(new KeyValuePair<object, CacheEntry>(entry.Key, entry)))