From 3d748900e26c58e64491fa11d136ae199a6764c6 Mon Sep 17 00:00:00 2001 From: Oriol Mesa Date: Thu, 17 Apr 2025 16:05:44 +0200 Subject: [PATCH] Include TryGetValue in activities that can trigger background scan --- aspnetcore/performance/caching/memory.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspnetcore/performance/caching/memory.md b/aspnetcore/performance/caching/memory.md index 7bd988edd124..8ac6304297d0 100644 --- a/aspnetcore/performance/caching/memory.md +++ b/aspnetcore/performance/caching/memory.md @@ -160,7 +160,7 @@ Using a allows multiple cache en ## Additional notes -* Expiration doesn't happen in the background. There's no timer that actively scans the cache for expired items. Any activity on the cache (`Get`, `Set`, `Remove`) can trigger a background scan for expired items. A timer on the `CancellationTokenSource` () also removes the entry and triggers a scan for expired items. The following example uses for the registered token. When this token fires, it removes the entry immediately and fires the eviction callbacks: +* Expiration doesn't happen in the background. There's no timer that actively scans the cache for expired items. Any activity on the cache (`Get`, `TryGetValue`, `Set`, `Remove`) can trigger a background scan for expired items. A timer on the `CancellationTokenSource` () also removes the entry and triggers a scan for expired items. The following example uses for the registered token. When this token fires, it removes the entry immediately and fires the eviction callbacks: :::code language="csharp" source="memory/samples/6.x/CachingMemorySample/Snippets/Pages/Index.cshtml.cs" id="snippet_OnGeCacheExpirationToken":::