FGutierrez.Core.Idempotency
1.1.9
dotnet add package FGutierrez.Core.Idempotency --version 1.1.9
NuGet\Install-Package FGutierrez.Core.Idempotency -Version 1.1.9
<PackageReference Include="FGutierrez.Core.Idempotency" Version="1.1.9" />
<PackageVersion Include="FGutierrez.Core.Idempotency" Version="1.1.9" />
<PackageReference Include="FGutierrez.Core.Idempotency" />
paket add FGutierrez.Core.Idempotency --version 1.1.9
#r "nuget: FGutierrez.Core.Idempotency, 1.1.9"
#:package FGutierrez.Core.Idempotency@1.1.9
#addin nuget:?package=FGutierrez.Core.Idempotency&version=1.1.9
#tool nuget:?package=FGutierrez.Core.Idempotency&version=1.1.9
โก FGutierrez.Core.Idempotency
๐ Overview
FGutierrez.Core.Idempotency is a high-performance .NET 8 library designed to guarantee that critical operations such as payments, order creation, and transactional workflows are executed exactly once, even in scenarios involving retries, duplicated requests, or network failures.
The library provides a distributed idempotency engine with multi-provider persistence support and built-in observability integrations.
๐ฏ Why This Library?
Implementing idempotency manually often introduces:
- Boilerplate middleware
- Duplicate business execution
- Inconsistent storage logic
- Poor traceability
- Lack of metrics and diagnostics
This library solves those challenges through a unified and extensible architecture.
โจ Features
| Feature | Description |
|---|---|
| โก High Performance | Optimized request interception pipeline |
| ๐ Multi-Provider | Redis or PostgreSQL support |
| ๐ Observability | OpenTelemetry metrics & tracing |
| โป Response Caching | Stores and replays original responses |
| ๐ Duplicate Prevention | Prevents re-execution of business operations |
| ๐งฉ Extensible | Provider-based architecture |
| ๐ Auto Schema | Automatic PostgreSQL schema generation |
๐ง Architecture
๐๏ธ Architecture & Workflow

๐ฆ Supported Providers
| Provider | Technology |
|---|---|
| PostgreSQL | Dapper |
| Redis | StackExchange.Redis |
๐ Observability
The library exposes native OpenTelemetry instrumentation for:
- Request duration
- Cache hits/misses
- Duplicate detection
- Storage latency
- Exception tracking
Compatible with:
- Jaeger
- Prometheus
- Grafana
- OTLP Collectors
๐ฆ Installation
dotnet add package FGutierrez.Core.Idempotency
โ๏ธ Configuration
๐ ๏ธ Infrastructure Setup (PostgreSQL)
Database Provisioning: The library automatically creates the required table (idempotency_keys) and indexes, but it requires the physical database to exist in the server.
Before running the application, ensure the database specified in your connection string is created:
CREATE DATABASE idempotency_db; -- or the name in your connection string (ConnectionStrings.Idempotency)
๐ Expiration Format (TimeSpan)
The Expiration field follows the standard .NET TimeSpan string format: [d.]hh:mm:ss.
Hour Overflow: In .NET, the hour component must be between 0 and 23. If you specify 24:00:00, the system will interpret it as 24 days instead of 24 hours.
To avoid misconfigurations, use the following guide:
| Desired Duration | Config Value | Explanation |
|---|---|---|
| 1 Hour | 01:00:00 |
Standard hh:mm:ss |
| 23 Hours | 23:00:00 |
Maximum hour value |
| 24 Hours (1 Day) | 1.00:00:00 |
Use d.hh:mm:ss (note the dot) |
| 30 Hours | 1.06:00:00 |
1 Day + 6 Hours |
| 7 Days | 7.00:00:00 |
7 Days |
appsettings.json
{
"ConnectionStrings": {
"Idempotency": "Host=localhost;Port=5432;Database=idempotency_db;Username=admin;Password=admin"
},
"Idempotency": {
"Enabled": true,
"Provider": "PostgreSQL",
"AllowedMethods": [ "POST", "PUT", "DELETE" ],
"HeaderName": "X-Idempotency-Key",
"Expiration": "06:00:00",
"MeterName": "FGutierrez.Core.Idempotency"
}
}
๐ Quick Start
Register Services
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddIdempotencyProvider(builder.Configuration);
var app = builder.Build();
Enable Middleware
app.UseIdempotency();
app.Run();
โ๏ธ Request Lifecycle
- Client sends a request with
X-Idempotency-Key - Middleware checks storage provider
- If the key exists:
- Cached response is returned
- If the key does not exist:
- Business logic executes normally
- Response is persisted
- Response is returned to the client
- Telemetry is exported automatically
๐ Requirements
- .NET 8 SDK
- PostgreSQL 16+ or Redis 7+
- Optional OpenTelemetry Collector
๐งช Future Roadmap
- SQL Server Provider
- MongoDB Provider
๐ค Contributing
Contributions are welcome.
To contribute:
- Fork the repository
- Create a feature branch
- Commit your changes
- Open a Pull Request
๐ License
MIT License ยฉ Federin Pastor Gutierrez Ortiz
โญ Support
If this project helped you, consider giving it a star on GitHub.
| 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 was computed. 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
- Dapper (>= 2.1.79)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.10)
- Microsoft.Extensions.Configuration (>= 8.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 8.0.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Options (>= 8.0.2)
- Npgsql (>= 8.0.3)
- OpenTelemetry.Api (>= 1.15.3)
- StackExchange.Redis (>= 2.13.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
# Release Notes - 1.1.3
- Refactor: Migrated agnostic registration to Core.
- Fix: Downgraded Npgsql to 8.0.3 to resolve TypeLoadException.
- Feature: Added AddIdempotencyProvider(IConfiguration) extension.
- Clean: Removed deprecated Http.Abstractions dependencies.
## [1.1.6] - 2026-05-26
### Fixed
- Correct Error: Fixed comparison error in AddIdempotencyProvider where ToUpperInvariant() did not match switch cases.