NetEvolve.Pulse.Redis
0.84.106
Prefix Reserved
dotnet add package NetEvolve.Pulse.Redis --version 0.84.106
NuGet\Install-Package NetEvolve.Pulse.Redis -Version 0.84.106
<PackageReference Include="NetEvolve.Pulse.Redis" Version="0.84.106" />
<PackageVersion Include="NetEvolve.Pulse.Redis" Version="0.84.106" />
<PackageReference Include="NetEvolve.Pulse.Redis" />
paket add NetEvolve.Pulse.Redis --version 0.84.106
#r "nuget: NetEvolve.Pulse.Redis, 0.84.106"
#:package NetEvolve.Pulse.Redis@0.84.106
#addin nuget:?package=NetEvolve.Pulse.Redis&version=0.84.106
#tool nuget:?package=NetEvolve.Pulse.Redis&version=0.84.106
NetEvolve.Pulse.Redis
Redis idempotency provider for Pulse using StackExchange.Redis. Implements IIdempotencyKeyRepository with atomic single round-trip operations for high-throughput, distributed idempotency enforcement: SET NX when no TimeToLive is set, and a server-side Lua script that also refreshes expired keys when a TimeToLive is set.
Features
- Without a
TimeToLive: atomicSET key value NXin a single round-trip - With a
TimeToLive: one atomic Lua script (EVAL) that reserves an absent key, or refreshes an expired key and resets itsPXexpiry - Keys namespaced as
{Schema}:{TableName}:{idempotencyKey}(defaultpulse:IdempotencyKey:{idempotencyKey}) - Logical TTL evaluated through
TimeProvider, plus a physical Redis expiry for automatic cleanup - Startup validation via
ValidateOnStart() - Requires
IConnectionMultiplexerregistered by the caller; the multiplexer's default database is used
Installation
NuGet Package Manager
Install-Package NetEvolve.Pulse.Redis
.NET CLI
dotnet add package NetEvolve.Pulse.Redis
PackageReference
<PackageReference Include="NetEvolve.Pulse.Redis" />
Quick Start
// 1. Register IConnectionMultiplexer (StackExchange.Redis)
services.AddSingleton<IConnectionMultiplexer>(_ =>
ConnectionMultiplexer.Connect("localhost:6379"));
// 2. Register the Redis idempotency store
services.AddPulse(config => config
.AddRedisIdempotencyStore()
);
Configuration
Configure the shared IdempotencyKeyOptions via code:
services.AddPulse(config => config
.AddRedisIdempotencyStore(opts =>
{
opts.Schema = "myapp";
opts.TableName = "idempotency";
opts.TimeToLive = TimeSpan.FromHours(48);
})
);
No configuration section is bound automatically. To use appsettings.json, bind the options yourself, for example
services.Configure<IdempotencyKeyOptions>(configuration.GetSection("MySection")).
Options
| Property | Default | Description |
|---|---|---|
Schema |
"pulse" |
First segment of the Redis key. null or empty yields an empty segment (:IdempotencyKey:{key}). |
TableName |
"IdempotencyKey" |
Second segment of the Redis key. Must not be null, empty, or whitespace. |
TimeToLive |
null |
Logical expiry. When null, keys never expire logically. When set, it must be greater than zero and at most TimeSpan.MaxValue minus one hour (the physical expiry adds one hour). |
The physical Redis expiry of each key is TimeToLive plus one hour. When TimeToLive is null, keys are stored without a Redis expiry. They are only removed if the server's maxmemory-policy evicts non-volatile keys (allkeys-*), and doing so breaks duplicate detection. Under volatile-* or noeviction policies the key space grows until the server runs out of memory. Set a TimeToLive if the key space must stay bounded.
When TimeToLive is set, reservation runs a Lua script. The Redis user must be allowed to run scripting commands (EVAL and EVALSHA, for example through the ACL category +@scripting). Managed tiers or ACLs that block scripting make reservation fail once a TimeToLive is configured.
The script compares stored timestamps as UTC round-trip text. The provider always writes UTC values. A value with a non-UTC offset, written by an earlier version through a direct IIdempotencyKeyRepository.StoreAsync call, is treated as present until its physical Redis expiry removes it. A value stored while TimeToLive was null has no physical expiry, so delete such keys manually if they must become reservable again.
Invalid options cause an OptionsValidationException at startup or on first resolution of the options.
Idempotency keys can be up to 450 characters long and are compared case-sensitively. See Idempotency Keys in the NetEvolve.Pulse README.
| 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 is compatible. 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. |
-
net10.0
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.14)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.14)
- NetEvolve.Pulse (>= 0.84.106)
- StackExchange.Redis (>= 3.4.31)
-
net8.0
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.14)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Options (>= 10.0.14)
- NetEvolve.Pulse (>= 0.84.106)
- StackExchange.Redis (>= 3.4.31)
-
net9.0
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.14)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Options (>= 10.0.14)
- NetEvolve.Pulse (>= 0.84.106)
- StackExchange.Redis (>= 3.4.31)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.