Wiaoj.Idempotency 0.2.0-alpha.3

This is a prerelease version of Wiaoj.Idempotency.
dotnet add package Wiaoj.Idempotency --version 0.2.0-alpha.3
                    
NuGet\Install-Package Wiaoj.Idempotency -Version 0.2.0-alpha.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Wiaoj.Idempotency" Version="0.2.0-alpha.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Wiaoj.Idempotency" Version="0.2.0-alpha.3" />
                    
Directory.Packages.props
<PackageReference Include="Wiaoj.Idempotency" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Wiaoj.Idempotency --version 0.2.0-alpha.3
                    
#r "nuget: Wiaoj.Idempotency, 0.2.0-alpha.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Wiaoj.Idempotency@0.2.0-alpha.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Wiaoj.Idempotency&version=0.2.0-alpha.3&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Wiaoj.Idempotency&version=0.2.0-alpha.3&prerelease
                    
Install as a Cake Tool

Wiaoj.Idempotency

The in-process IIdempotencyStore: a concurrent dictionary of claims with TTL expiry.

dotnet add package Wiaoj.Idempotency

Usage

builder.Services.AddInMemoryIdempotencyStore();
public sealed class OrderHandler(IIdempotencyStore claims) {
    public async Task HandleAsync(OrderPlaced message, CancellationToken ct) {
        IdempotencyKey key = new($"order-placed:{message.OrderId}");

        if(!await claims.TryMarkProcessedAsync(key, TimeSpan.FromHours(24), ct)) {
            return;   // someone already handled it
        }

        try {
            await DoTheWorkAsync(message, ct);
        }
        catch {
            await claims.RemoveAsync(key, ct);   // release the claim so a retry can run
            throw;
        }
    }
}
  • Atomic: TryMarkProcessedAsync uses a compare-and-swap loop, so exactly one caller wins a key within one process.
  • Expiry: an entry past its window counts as absent and is replaced in place; there is no background sweep.
  • Time: it takes a TimeProvider, so tests control expiry instead of sleeping.

When this store is not enough

Claims live in this process's memory, so they are forgotten on restart and not shared between replicas — which is exactly when a message is redelivered. Use Wiaoj.Idempotency.Redis for anything running more than one process, or a process that can restart mid-flight.

Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.2.0-alpha.3 33 9/24/2026
0.2.0-alpha.2 32 9/24/2026
0.2.0-alpha.1 35 9/24/2026
0.1.0-alpha.9 51 9/21/2026
0.1.0-alpha.8 41 9/21/2026