DKNet.AspCore.Idempotency.NpgsqlStore 10.0.35

dotnet add package DKNet.AspCore.Idempotency.NpgsqlStore --version 10.0.35
                    
NuGet\Install-Package DKNet.AspCore.Idempotency.NpgsqlStore -Version 10.0.35
                    
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="DKNet.AspCore.Idempotency.NpgsqlStore" Version="10.0.35" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DKNet.AspCore.Idempotency.NpgsqlStore" Version="10.0.35" />
                    
Directory.Packages.props
<PackageReference Include="DKNet.AspCore.Idempotency.NpgsqlStore" />
                    
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 DKNet.AspCore.Idempotency.NpgsqlStore --version 10.0.35
                    
#r "nuget: DKNet.AspCore.Idempotency.NpgsqlStore, 10.0.35"
                    
#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 DKNet.AspCore.Idempotency.NpgsqlStore@10.0.35
                    
#: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=DKNet.AspCore.Idempotency.NpgsqlStore&version=10.0.35
                    
Install as a Cake Addin
#tool nuget:?package=DKNet.AspCore.Idempotency.NpgsqlStore&version=10.0.35
                    
Install as a Cake Tool

DKNet.AspCore.Idempotency.NpgsqlStore

PostgreSQL persistent storage implementation for DKNet.AspCore.Idempotency.

Overview

This library provides a PostgreSQL-backed storage implementation for idempotency keys, replacing the default distributed-cache storage. It uses Entity Framework Core 10 with the Npgsql provider, and detects concurrent duplicate inserts via Postgres's own unique-violation error code (23505) rather than message inspection.

Installation

dotnet add package DKNet.AspCore.Idempotency.NpgsqlStore

Quick Start

using DKNet.AspCore.Idempotency.NpgsqlStore;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddIdempotencyWithNpgsqlStore(
    builder.Configuration.GetConnectionString("IdempotencyDb")!,
    options =>
    {
        options.Expiration = TimeSpan.FromHours(24);
        options.ConflictHandling = IdempotentConflictHandling.CachedResult;
    });

var app = builder.Build();

app.MapPost("/orders", CreateOrder).RequiredIdempotentKey();

app.Run();

appsettings.json:

{
  "ConnectionStrings": {
    "IdempotencyDb": "Host=localhost;Database=MyAppIdempotency;Username=app;Password=changeit"
  }
}

Database Schema

A single IdempotencyKeys table, with a unique index (UX_CompositeKey) on CompositeKey that guarantees exactly one stored entry per idempotency key/endpoint/method combination, and a check constraint (CK_StatusCode_Valid) restricting StatusCode to the 100-599 range.

Concurrency Handling

Concurrent requests with the same idempotency key race to insert; the loser's DbUpdateException is inspected for PostgresException.SqlState == PostgresErrorCodes.UniqueViolation ("23505") and swallowed, so only one entry is ever persisted — no application-level locking required.

Requirements

  • .NET 10.0+
  • PostgreSQL 13+
  • DKNet.AspCore.Idempotency (automatically included)

License

MIT License - see LICENSE file for details.

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
10.0.35 34 8/5/2026
10.0.34 34 8/5/2026
10.0.33 37 8/4/2026