IdempotencyGuard.PostgreSql
1.2.2
dotnet add package IdempotencyGuard.PostgreSql --version 1.2.2
NuGet\Install-Package IdempotencyGuard.PostgreSql -Version 1.2.2
<PackageReference Include="IdempotencyGuard.PostgreSql" Version="1.2.2" />
<PackageVersion Include="IdempotencyGuard.PostgreSql" Version="1.2.2" />
<PackageReference Include="IdempotencyGuard.PostgreSql" />
paket add IdempotencyGuard.PostgreSql --version 1.2.2
#r "nuget: IdempotencyGuard.PostgreSql, 1.2.2"
#:package IdempotencyGuard.PostgreSql@1.2.2
#addin nuget:?package=IdempotencyGuard.PostgreSql&version=1.2.2
#tool nuget:?package=IdempotencyGuard.PostgreSql&version=1.2.2
IdempotencyGuard.PostgreSql
PostgreSQL-backed idempotency store for the IdempotencyGuard library. Uses INSERT ... ON CONFLICT DO NOTHING for atomic claim operations and supports automatic schema provisioning.
Installation
dotnet add package IdempotencyGuard.AspNetCore
dotnet add package IdempotencyGuard.PostgreSql
Setup
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddIdempotencyGuard(options =>
{
options.MissingKeyPolicy = MissingKeyPolicy.Reject;
});
builder.Services.AddIdempotencyGuardPostgresStore(options =>
{
options.ConnectionString = "Host=localhost;Database=myapp";
options.TableName = "idempotency_entries"; // default
options.AutoCreateTable = true; // creates table on first use
});
var app = builder.Build();
app.UseIdempotencyGuard();
How it works
- Claim —
INSERT ... ON CONFLICT DO NOTHINGfor atomic key acquisition with fingerprint validation - Complete —
UPDATEto store the response body, headers, and status code - Release —
DELETEto remove the claim after processing failure - Cleanup —
DELETE ... FOR UPDATE SKIP LOCKEDvia the background cleanup service for safe concurrent purging
Schema
When AutoCreateTable = true, the store creates the following table on first use:
CREATE TABLE idempotency_entries (
key TEXT NOT NULL PRIMARY KEY,
request_fingerprint TEXT NOT NULL,
state TEXT NOT NULL,
claimed_at TIMESTAMPTZ NOT NULL,
completed_at TIMESTAMPTZ,
expires_at TIMESTAMPTZ NOT NULL,
status_code INTEGER,
headers_json TEXT,
response_body BYTEA
);
Expired entry cleanup
Expired entries are purged by the built-in background service. Configure the cleanup interval and batch size:
builder.Services.AddIdempotencyGuard(options =>
{
options.Cleanup.Interval = TimeSpan.FromMinutes(5);
options.Cleanup.BatchSize = 1_000;
});
Documentation
See the full documentation on GitHub for middleware configuration, selective fingerprinting, and production deployment guides.
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 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
- IdempotencyGuard (>= 1.2.2)
- Microsoft.Extensions.Options (>= 8.0.2)
- Npgsql (>= 8.0.6)
-
net9.0
- IdempotencyGuard (>= 1.2.2)
- Microsoft.Extensions.Options (>= 8.0.2)
- Npgsql (>= 8.0.6)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.