Microsoft.Extensions.Caching.Hybrid 10.0.0
Microsoft.Extensions.Caching.Hybrid
This package contains a concrete implementation of the HybridCache API,
simplifying and enhancing cache usage that might previously have been built on top of IDistributedCache.
Key features:
- built on top of
IDistributedCache- all existing cache backends (Redis, SQL Server, CosmosDB, etc) should work immediately - simple API (all the cache, serialization, etc details from are encapsulated)
- cache-stampede protection (combining of concurrent requests for the same data)
- performance enhancements such as inbuilt support for the newer
IBufferDistributedCacheAPI - fully configurable serialization
Full HybridCache documentation is here.
Full documentation
See learn.microsoft.com for full discussion of HybridCache.
Install the package
From the command-line:
dotnet add package Microsoft.Extensions.Caching.Hybrid
Or directly in the C# project file:
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Caching.Hybrid" Version="[CURRENTVERSION]" />
</ItemGroup>
Usage example
The HybridCache service can be registered and configured via IServiceCollection, for example:
builder.Services.AddHybridCache(/* optional configuration /*);
Note that in many cases you may also wish to register a distributed cache backend, as discussed here; for example a Redis instance:
builder.Services.AddStackExchangeRedisCache(options =>
{
options.Configuration = builder.Configuration.GetConnectionString("MyRedisConStr");
});
Once registered, the HybridCache instance can be obtained via dependency-injection, allowing the
GetOrCreateAsync API to be used to obtain data:
public class SomeService(HybridCache cache)
{
private HybridCache _cache = cache;
public async Task<SomeDataType> GetSomeInfoAsync(string name, int id, CancellationToken token = default)
{
return await _cache.GetOrCreateAsync(
$"{name}-{id}", // Unique key to the cache entry
async cancel => await GetDataFromTheSourceAsync(name, id, cancel),
cancellationToken: token
);
}
private async Task<SomeDataType> GetDataFromTheSourceAsync(string name, int id, CancellationToken token)
{
// talk to the underlying data store here - could be SQL, gRPC, HTTP, etc
}
}
Additional usage guidance - including expiration, custom serialization support, and alternate usage to reduce delegate allocation - is available on learn.microsoft.com.
No packages depend on Microsoft.Extensions.Caching.Hybrid.
.NET Framework 4.6.2
- Microsoft.Bcl.TimeProvider (>= 10.0.0)
- Microsoft.Extensions.Caching.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Caching.Memory (>= 10.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Options (>= 10.0.0)
- System.Text.Json (>= 10.0.0)
.NET 8.0
- Microsoft.Extensions.Caching.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Caching.Memory (>= 10.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Options (>= 10.0.0)
.NET 9.0
- Microsoft.Extensions.Caching.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Caching.Memory (>= 10.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Options (>= 10.0.0)
.NET 10.0
- Microsoft.Extensions.Caching.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Caching.Memory (>= 10.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Options (>= 10.0.0)
.NET Standard 2.0
- Microsoft.Bcl.TimeProvider (>= 10.0.0)
- Microsoft.Extensions.Caching.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Caching.Memory (>= 10.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Options (>= 10.0.0)
- System.Text.Json (>= 10.0.0)
.NET Standard 2.1
- Microsoft.Bcl.TimeProvider (>= 10.0.0)
- Microsoft.Extensions.Caching.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Caching.Memory (>= 10.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Options (>= 10.0.0)
- System.Text.Json (>= 10.0.0)
| Version | Downloads | Last updated |
|---|---|---|
| 10.0.0 | 1 | 12/04/2025 |
| 9.10.0 | 0 | 10/14/2025 |
| 9.9.0 | 0 | 09/09/2025 |
| 9.8.0 | 0 | 08/12/2025 |
| 9.7.0 | 0 | 07/08/2025 |
| 9.6.0 | 0 | 06/10/2025 |
| 9.5.0 | 0 | 05/13/2025 |
| 9.4.0 | 0 | 04/08/2025 |
| 9.3.0 | 0 | 03/11/2025 |
| 9.2.0-preview.1.25105.6 | 0 | 02/11/2025 |
| 9.1.0-preview.1.25064.3 | 0 | 01/14/2025 |
| 9.0.0-preview.9.24556.5 | 0 | 11/12/2024 |
| 9.0.0-preview.9.24507.7 | 0 | 10/08/2024 |
| 9.0.0-preview.7.24406.2 | 0 | 08/13/2024 |
| 9.0.0-preview.6.24328.4 | 0 | 07/09/2024 |
| 9.0.0-preview.5.24306.11 | 0 | 06/11/2024 |
| 9.0.0-preview.4.24267.6 | 0 | 05/21/2024 |