IdempotencyGuard 2.1.0
dotnet add package IdempotencyGuard --version 2.1.0
NuGet\Install-Package IdempotencyGuard -Version 2.1.0
<PackageReference Include="IdempotencyGuard" Version="2.1.0" />
<PackageVersion Include="IdempotencyGuard" Version="2.1.0" />
<PackageReference Include="IdempotencyGuard" />
paket add IdempotencyGuard --version 2.1.0
#r "nuget: IdempotencyGuard, 2.1.0"
#:package IdempotencyGuard@2.1.0
#addin nuget:?package=IdempotencyGuard&version=2.1.0
#tool nuget:?package=IdempotencyGuard&version=2.1.0
IdempotencyGuard
Core abstractions and in-memory store for the IdempotencyGuard library. This package provides the foundational types, interfaces, and an in-memory store implementation for idempotent HTTP API request handling.
What's in this package
IIdempotencyStore— store interface for claim/response lifecycleIPurgableIdempotencyStore— extension interface for stores that support expired entry cleanupIDownstreamKeyGenerator/IIdempotencyContext— deterministic key generation for downstream service callsInMemoryIdempotencyStore— in-memory store for development and testingRequestFingerprint— SHA256-based request fingerprinting with JSON normalisation- Built-in metrics via
System.Diagnostics.Metricsunder theIdempotencyGuardmeter
When to use this package directly
Most applications should install IdempotencyGuard.AspNetCore instead, which includes this package as a dependency and adds the ASP.NET Core middleware.
Install this package directly if you are:
- Building a custom store implementation
- Using the fingerprinting or key generation utilities outside of ASP.NET Core
- Writing a non-ASP.NET Core host that needs the core abstractions
Installation
dotnet add package IdempotencyGuard
Implementing a custom store
public class MyCustomStore : IIdempotencyStore
{
public Task<ClaimResult> TryClaimAsync(string key, string fingerprint, TimeSpan claimTtl, CancellationToken ct = default)
{
// Atomically claim the key or return the existing state. Treat expired entries as absent.
// On success, persist a new unique token and return new ClaimResult.Claimed(token).
}
public Task<bool> SetResponseAsync(string key, string claimToken, IdempotentResponse response, TimeSpan responseTtl, CancellationToken ct = default)
{
// Atomically store the response, only if the entry is still claimed under claimToken.
// Return whether it was stored.
}
public Task<IdempotentResponse?> GetResponseAsync(string key, CancellationToken ct = default)
{
// Retrieve a cached response
}
public Task<bool> ReleaseClaimAsync(string key, string claimToken, CancellationToken ct = default)
{
// Atomically remove the entry, only if it is still claimed under claimToken.
// Return whether it was removed.
}
}
Available store packages
| Store | Package |
|---|---|
| Redis | IdempotencyGuard.Redis |
| PostgreSQL | IdempotencyGuard.PostgreSql |
| SQL Server | IdempotencyGuard.SqlServer |
Documentation
See the full documentation on GitHub for configuration, usage guides, and examples.
License
MIT
| 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
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (4)
Showing the top 4 NuGet packages that depend on IdempotencyGuard:
| Package | Downloads |
|---|---|
|
IdempotencyGuard.AspNetCore
Idempotency-Key middleware for ASP.NET Core. Stops retries and concurrent duplicates from running a request twice, with request fingerprinting, response replay and per-endpoint configuration for controllers and minimal APIs. |
|
|
IdempotencyGuard.Redis
Redis store for IdempotencyGuard, an Idempotency-Key middleware library for ASP.NET Core. Uses atomic Lua scripts for distributed claim coordination and response caching via StackExchange.Redis. |
|
|
IdempotencyGuard.PostgreSql
PostgreSQL store for IdempotencyGuard, an Idempotency-Key middleware library for ASP.NET Core. Uses INSERT ON CONFLICT for durable claim coordination and response caching, with automatic schema provisioning. |
|
|
IdempotencyGuard.SqlServer
SQL Server store for IdempotencyGuard, an Idempotency-Key middleware library for ASP.NET Core. Uses MERGE for durable claim coordination and response caching, with automatic schema provisioning. |
GitHub repositories
This package is not used by any popular GitHub repositories.