Skip to content

Commit 1365bdc

Browse files
Update cache in background (#18295)
* Update cache in background * Update cache in background
1 parent c187785 commit 1365bdc

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

aspnetcore/performance/caching/memory.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ Using a <xref:System.Threading.CancellationTokenSource> allows multiple cache en
175175
* Use <xref:Microsoft.Extensions.Caching.Memory.ICacheEntry.PostEvictionCallbacks> to set the callbacks that will be fired after the cache entry is evicted from the cache.
176176
* For most apps, `IMemoryCache` is enabled. For example, calling `AddMvc`, `AddControllersWithViews`, `AddRazorPages`, `AddMvcCore().AddRazorViewEngine`, and many other `Add{Service}` methods in `ConfigureServices`, enables `IMemoryCache`. For apps that are not calling one of the preceding `Add{Service}` methods, it may be necessary to call <xref:Microsoft.Extensions.DependencyInjection.MemoryCacheServiceCollectionExtensions.AddMemoryCache*> in `ConfigureServices`.
177177

178+
## Background cache update
179+
180+
Use a [background service](xref:fundamentals/host/hosted-services) such as <xref:Microsoft.Extensions.Hosting.IHostedService> to update the cache. The background service can recompute the entries and then assign them to the cache only when they’re ready.
181+
178182
## Additional resources
179183

180184
* <xref:performance/caching/distributed>
@@ -342,6 +346,10 @@ Using a `CancellationTokenSource` allows multiple cache entries to be evicted as
342346

343347
* Use [PostEvictionCallbacks](/dotnet/api/microsoft.extensions.caching.memory.icacheentry.postevictioncallbacks#Microsoft_Extensions_Caching_Memory_ICacheEntry_PostEvictionCallbacks) to set the callbacks that will be fired after the cache entry is evicted from the cache.
344348

349+
## Background cache update
350+
351+
Use a [background service](xref:fundamentals/host/hosted-services) such as <xref:Microsoft.Extensions.Hosting.IHostedService> to update the cache. The background service can recompute the entries and then assign them to the cache only when they’re ready.
352+
345353
## Additional resources
346354

347355
* <xref:performance/caching/distributed>

0 commit comments

Comments
 (0)