1 instantiation of CacheEntry
Microsoft.Extensions.Caching.Memory (1)
MemoryCache.cs (1)
120return new CacheEntry(key, this);
52 references to CacheEntry
Microsoft.Extensions.Caching.Memory (52)
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 (37)
123internal void SetEntry(CacheEntry entry) 154if (coherentState.TryGetValue(entry.Key, out CacheEntry? priorEntry)) 227coherentState.TryGetValue(key, out CacheEntry? entry); // note we rely on documented "default when fails" contract re the out 244coherentState.TryGetValue(key, out CacheEntry? entry); // note we rely on documented "default when fails" contract re the out 280private bool PostProcessTryGetValue(CoherentState coherentState, CacheEntry? entry, out object? result) 346if (coherentState.TryRemove(key, out CacheEntry? entry)) 368foreach (CacheEntry entry in oldState.GetAllValues()) 397internal void EntryExpired(CacheEntry entry) 509foreach (CacheEntry entry in coherentState.GetAllValues()) 529private bool UpdateCacheSizeExceedsCapacity(CacheEntry entry, CacheEntry? priorEntry, CoherentState coherentState) 624private void Compact(long removalSizeTarget, Func<CacheEntry, long> computeEntrySize, CoherentState coherentState) 626var entriesToRemove = new List<CacheEntry>(); 628var lowPriEntries = new List<(CacheEntry entry, DateTime lastAccessed)>(); 629var normalPriEntries = new List<(CacheEntry entry, DateTime lastAccessed)>(); 630var highPriEntries = new List<(CacheEntry entry, DateTime lastAccessed)>(); 635foreach (CacheEntry entry in coherentState.GetAllValues()) 668foreach (CacheEntry entry in entriesToRemove) 686static void ExpirePriorityBucket(ref long removedSize, long removalSizeTarget, Func<CacheEntry, long> computeEntrySize, List<CacheEntry> entriesToRemove, List<(CacheEntry Entry, DateTime LastAccessed)> priorityEntries) 700foreach ((CacheEntry entry, _) in priorityEntries) 768private readonly ConcurrentDictionary<string, CacheEntry> _stringEntries = []; 772private readonly ConcurrentDictionary<object, CacheEntry> _nonStringEntries = []; 775private readonly ConcurrentDictionary<string, CacheEntry>.AlternateLookup<ReadOnlySpan<char>> _stringAltLookup; 785internal bool TryGetValue(object key, [NotNullWhen(true)] out CacheEntry? entry) 789internal bool TryGetValue(ReadOnlySpan<char> key, [NotNullWhen(true)] out CacheEntry? entry) 794internal bool TryRemove(object key, [NotNullWhen(true)] out CacheEntry? entry) 797internal bool TryAdd(object key, CacheEntry entry) 800internal bool TryUpdate(object key, CacheEntry entry, CacheEntry comparison) 803public IEnumerable<CacheEntry> GetAllValues() 809foreach (KeyValuePair<string, CacheEntry> entry in _stringEntries) 813foreach (KeyValuePair<object, CacheEntry> entry in _nonStringEntries) 821foreach (KeyValuePair<string, CacheEntry> pairs in _stringEntries) 825foreach (KeyValuePair<object, CacheEntry> pairs in _nonStringEntries) 835internal bool RemoveEntry(CacheEntry entry, MemoryCacheOptions options)