TransactR.DistributedMemoryCache
0.3.2
dotnet add package TransactR.DistributedMemoryCache --version 0.3.2
NuGet\Install-Package TransactR.DistributedMemoryCache -Version 0.3.2
<PackageReference Include="TransactR.DistributedMemoryCache" Version="0.3.2" />
<PackageVersion Include="TransactR.DistributedMemoryCache" Version="0.3.2" />
<PackageReference Include="TransactR.DistributedMemoryCache" />
paket add TransactR.DistributedMemoryCache --version 0.3.2
#r "nuget: TransactR.DistributedMemoryCache, 0.3.2"
#:package TransactR.DistributedMemoryCache@0.3.2
#addin nuget:?package=TransactR.DistributedMemoryCache&version=0.3.2
#tool nuget:?package=TransactR.DistributedMemoryCache&version=0.3.2
TransactR.DistributedMemoryCache
TransactR.DistributedMemoryCache
provides an implementation of IMementoStore
using the IDistributedCache
service, ideal for high-performance and scalable applications that leverage distributed caching.
Installation
First, install the NuGet package into your project.
dotnet add package TransactR.DistributedMemoryCache
Configuration
To use the distributed cache as your memento store, you need to configure IDistributedCache
and then add the TransactR
service. This example assumes you are using Redis.
// Program.cs
builder.Services.AddStackExchangeRedisCache(options =>
{
options.Configuration = "your_redis_connection_string";
options.InstanceName = "TransactR_";
});
builder.Services.AddDistributedCacheMementoStore<IlMioStato, int>();
Usage
After configuration, you can inject IMementoStore<IlMioStato, int>
into your services or controllers to save and retrieve mementos.
public class MyService
{
private readonly IMementoStore<IlMioStato, int> _mementoStore;
public MyService(IMementoStore<IlMioStato, int> mementoStore)
{
_mementoStore = mementoStore;
}
public async Task PerformOperationAsync(string transactionId, IlMioStato state)
{
// Save a new memento with step 1
await _mementoStore.SaveAsync(transactionId, 1, state);
// Retrieve the memento
var recoveredMemento = await _mementoStore.RetrieveAsync(transactionId, 1);
}
}
IlMioStato
is a class that can be serialized to JSON.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Microsoft.Extensions.Caching.Abstractions (>= 8.0.0)
- TransactR (>= 0.3.2)
-
net9.0
- Microsoft.Extensions.Caching.Abstractions (>= 8.0.0)
- TransactR (>= 0.3.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.