Microsoft.Extensions.Caching.Hybrid
9.0.0-preview.9.24507.7
Prefix Reserved
See the version list below for details.
dotnet add package Microsoft.Extensions.Caching.Hybrid --version 9.0.0-preview.9.24507.7
NuGet\Install-Package Microsoft.Extensions.Caching.Hybrid -Version 9.0.0-preview.9.24507.7
<PackageReference Include="Microsoft.Extensions.Caching.Hybrid" Version="9.0.0-preview.9.24507.7" />
paket add Microsoft.Extensions.Caching.Hybrid --version 9.0.0-preview.9.24507.7
#r "nuget: Microsoft.Extensions.Caching.Hybrid, 9.0.0-preview.9.24507.7"
// Install Microsoft.Extensions.Caching.Hybrid as a Cake Addin #addin nuget:?package=Microsoft.Extensions.Caching.Hybrid&version=9.0.0-preview.9.24507.7&prerelease // Install Microsoft.Extensions.Caching.Hybrid as a Cake Tool #tool nuget:?package=Microsoft.Extensions.Caching.Hybrid&version=9.0.0-preview.9.24507.7&prerelease
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
IBufferDistributedCache
API - 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.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- Microsoft.Bcl.TimeProvider (>= 9.0.0-rc.2.24473.5)
- Microsoft.Extensions.Caching.Abstractions (>= 9.0.0-rc.2.24473.5)
- Microsoft.Extensions.Caching.Memory (>= 9.0.0-rc.2.24473.5)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0-rc.2.24473.5)
- Microsoft.Extensions.Options (>= 9.0.0-rc.2.24473.5)
- System.Text.Json (>= 9.0.0-rc.2.24473.5)
-
.NETStandard 2.0
- Microsoft.Bcl.TimeProvider (>= 9.0.0-rc.2.24473.5)
- Microsoft.Extensions.Caching.Abstractions (>= 9.0.0-rc.2.24473.5)
- Microsoft.Extensions.Caching.Memory (>= 9.0.0-rc.2.24473.5)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0-rc.2.24473.5)
- Microsoft.Extensions.Options (>= 9.0.0-rc.2.24473.5)
- System.Text.Json (>= 9.0.0-rc.2.24473.5)
-
.NETStandard 2.1
- Microsoft.Bcl.TimeProvider (>= 9.0.0-rc.2.24473.5)
- Microsoft.Extensions.Caching.Abstractions (>= 9.0.0-rc.2.24473.5)
- Microsoft.Extensions.Caching.Memory (>= 9.0.0-rc.2.24473.5)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0-rc.2.24473.5)
- Microsoft.Extensions.Options (>= 9.0.0-rc.2.24473.5)
- System.Text.Json (>= 9.0.0-rc.2.24473.5)
-
net8.0
- Microsoft.Extensions.Caching.Abstractions (>= 9.0.0-rc.2.24473.5)
- Microsoft.Extensions.Caching.Memory (>= 9.0.0-rc.2.24473.5)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0-rc.2.24473.5)
- Microsoft.Extensions.Options (>= 9.0.0-rc.2.24473.5)
-
net9.0
- Microsoft.Extensions.Caching.Abstractions (>= 9.0.0-rc.2.24473.5)
- Microsoft.Extensions.Caching.Memory (>= 9.0.0-rc.2.24473.5)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0-rc.2.24473.5)
- Microsoft.Extensions.Options (>= 9.0.0-rc.2.24473.5)
NuGet packages (10)
Showing the top 5 NuGet packages that depend on Microsoft.Extensions.Caching.Hybrid:
Package | Downloads |
---|---|
Volo.Abp.Caching
Package Description |
|
Altinn.App.Core
This class library holds all the core features used by a standard Altinn 3 App. |
|
Jakar.Database
Package Description |
|
Hexalith.Infrastructure.ClientAppOnServer
Hexalith is a set of libraries to build a micro-service architecture. |
|
Umbraco.Cms.PublishedCache.HybridCache
Contains the published cache assembly needed to run Umbraco CMS. |
GitHub repositories (6)
Showing the top 5 popular GitHub repositories that depend on Microsoft.Extensions.Caching.Hybrid:
Repository | Stars |
---|---|
abpframework/abp
Open-source web application framework for ASP.NET Core! Offers an opinionated architecture to build enterprise software solutions with best practices on top of the .NET. Provides the fundamental infrastructure, cross-cutting-concern implementations, startup templates, application modules, UI themes, tooling and documentation.
|
|
dotnet/AspNetCore.Docs
Documentation for ASP.NET Core
|
|
umbraco/Umbraco-CMS
Umbraco is a free and open source .NET content management system helping you deliver delightful digital experiences.
|
|
ZiggyCreatures/FusionCache
FusionCache is an easy to use, fast and robust hybrid cache with advanced resiliency features.
|
|
erwinkramer/bank-api
The Bank API is a design reference project suitable to bootstrap development for a compliant and modern API.
|
Version | Downloads | Last updated |
---|---|---|
9.0.0-preview.9.24556.5 | 39,411 | 11/12/2024 |
9.0.0-preview.9.24507.7 | 20,783 | 10/8/2024 |
9.0.0-preview.7.24406.2 | 70,126 | 8/13/2024 |
9.0.0-preview.6.24328.4 | 42,725 | 7/9/2024 |
9.0.0-preview.5.24306.11 | 28,565 | 6/11/2024 |
9.0.0-preview.4.24267.6 | 8,321 | 5/21/2024 |