Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion aspnetcore/performance/caching/hybrid.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
![image](https://github.com/user-attachments/assets/4ab2cb54-5bb8-41f3-b1b0-449c999f8ae0)---
title: HybridCache library in ASP.NET Core
author: tdykstra
description: Learn how to use HybridCache library in ASP.NET Core.
Expand Down Expand Up @@ -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.

Tags can be used to group cache entries and invalidate them together.

Set tags when calling `GetOrCreateAsync`, as shown in the following example:
Expand Down Expand Up @@ -145,6 +148,8 @@ For more information, see the [HybridCache serialization sample app](https://git

By default `HybridCache` uses <xref:System.Runtime.Caching.MemoryCache> 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).

One important thing to also keep in mind is that 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, but the other nodes in-memory cache isn't invalidated.

## Optimize performance

To optimize performance, configure `HybridCache` to reuse objects and avoid `byte[]` allocations.
Expand Down
Loading