From 559e2ff960b80ed48bcaab8f71d78338144464f8 Mon Sep 17 00:00:00 2001 From: "Wilson Neto B.R." Date: Wed, 27 Nov 2024 01:23:00 -0300 Subject: [PATCH 1/3] Add important notes on HybridCache limitations and behavior - Added a note indicating that removing cache entries by tag is still under development and is currently non-functional. - Clarified that cache invalidation by key or tags affects only the current node and secondary storage, but not other nodes' in-memory cache. Ask Copilot --- aspnetcore/performance/caching/hybrid.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/aspnetcore/performance/caching/hybrid.md b/aspnetcore/performance/caching/hybrid.md index 6a7f1612caed..013c87f01d73 100644 --- a/aspnetcore/performance/caching/hybrid.md +++ b/aspnetcore/performance/caching/hybrid.md @@ -73,6 +73,9 @@ When an entry is removed, it is removed from both the primary and secondary cach ## Remove cache entries by tag +> [!IMPORTANT] +> This feature is still under development. If you try to remove entries by tag, you will notice that it won't cause any effect yet. + Tags can be used to group cache entries and invalidate them together. Set tags when calling `GetOrCreateAsync`, as shown in the following example: @@ -145,6 +148,8 @@ For more information, see the [HybridCache serialization sample app](https://git By default `HybridCache` uses for its primary cache storage. Cache entries are stored in-process, so each server has a separate cache that is lost whenever the server process is restarted. For secondary out-of-process storage, such as Redis or SQL Server, `HybridCache` uses [the configured `IDistributedCache` implementation](xref:performance/caching/distributed), if any. But even without an `IDistributedCache`implementation, the `HybridCache` service still provides in-process caching and [stampede protection](https://en.wikipedia.org/wiki/Cache_stampede). +**Note:** When invalidating the cache by key or by tags, it will be invalidated in the current node and in the secondary out-of-process storage. However, the in-memory cache on other nodes will not be affected. + ## Optimize performance To optimize performance, configure `HybridCache` to reuse objects and avoid `byte[]` allocations. From 300f015efb2a56e8607da5ead51f1fca4b6c5678 Mon Sep 17 00:00:00 2001 From: "Wilson Neto B.R." Date: Sat, 30 Nov 2024 23:52:09 -0300 Subject: [PATCH 2/3] Update aspnetcore/performance/caching/hybrid.md based on PR suggestions Co-authored-by: Tom Dykstra --- aspnetcore/performance/caching/hybrid.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/aspnetcore/performance/caching/hybrid.md b/aspnetcore/performance/caching/hybrid.md index 013c87f01d73..172ae7dbebbc 100644 --- a/aspnetcore/performance/caching/hybrid.md +++ b/aspnetcore/performance/caching/hybrid.md @@ -148,7 +148,8 @@ For more information, see the [HybridCache serialization sample app](https://git By default `HybridCache` uses for its primary cache storage. Cache entries are stored in-process, so each server has a separate cache that is lost whenever the server process is restarted. For secondary out-of-process storage, such as Redis or SQL Server, `HybridCache` uses [the configured `IDistributedCache` implementation](xref:performance/caching/distributed), if any. But even without an `IDistributedCache`implementation, the `HybridCache` service still provides in-process caching and [stampede protection](https://en.wikipedia.org/wiki/Cache_stampede). -**Note:** When invalidating the cache by key or by tags, it will be invalidated in the current node and in the secondary out-of-process storage. However, the in-memory cache on other nodes will not be affected. +> [!NOTE] +> When invalidating cache entries by key or by tags, they are invalidated in the current server and in the secondary out-of-process storage. However, the in-memory cache in other servers isn't affected. ## Optimize performance From 08192e0acf12e12d978fdfde62a1f472456aabcf Mon Sep 17 00:00:00 2001 From: "Wilson Neto B.R." Date: Sat, 30 Nov 2024 23:52:46 -0300 Subject: [PATCH 3/3] Update aspnetcore/performance/caching/hybrid.md Co-authored-by: Tom Dykstra --- aspnetcore/performance/caching/hybrid.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspnetcore/performance/caching/hybrid.md b/aspnetcore/performance/caching/hybrid.md index 172ae7dbebbc..6c333e68b4e0 100644 --- a/aspnetcore/performance/caching/hybrid.md +++ b/aspnetcore/performance/caching/hybrid.md @@ -74,7 +74,7 @@ When an entry is removed, it is removed from both the primary and secondary cach ## Remove cache entries by tag > [!IMPORTANT] -> This feature is still under development. If you try to remove entries by tag, you will notice that it won't cause any effect yet. +> This feature is still under development. If you try to remove entries by tag, you will notice that it doesn't have any effect. Tags can be used to group cache entries and invalidate them together.