Skip to content

feat: IIdempotencyStore – SQLite ADO.NET implementation #229

@samtrion

Description

@samtrion

User Story

As a developer using SQLite with Pulse, I want an IIdempotencyStore backed by SQLite, so that I can enforce idempotency in embedded, edge, or test scenarios without requiring a full database server.


Background

Mirrors the SQL Server (#227) and PostgreSQL (#228) implementations but uses Microsoft.Data.Sqlite and SQLite-specific DDL (TEXT for ISO-8601 timestamps, INSERT OR IGNORE).


Requirements

  • Add src/NetEvolve.Pulse.SQLite/Scripts/002_CreateIdempotencyKeyTable.sql:
    • CREATE TABLE IF NOT EXISTS "{table}" ("IdempotencyKey" TEXT NOT NULL PRIMARY KEY, "CreatedAt" TEXT NOT NULL) using ISO-8601 strings for DateTimeOffset.
  • Create SQLiteIdempotencyKeyOptions: ConnectionString, TableName, EnableWalMode, TimeToLive?.
  • Implement SQLiteIdempotencyStore : IIdempotencyStore via Microsoft.Data.Sqlite:
    • ExistsAsync: SELECT 1 FROM "..." WHERE "IdempotencyKey" = @key LIMIT 1.
    • StoreAsync: INSERT OR IGNORE INTO "..." VALUES (@key, @createdAt).
  • Expose AddSQLiteIdempotencyStore extension overloads in SQLiteIdempotencyMediatorBuilderExtensions.

Acceptance Criteria

  • DDL script creates the table using SQLite syntax and ISO-8601 text columns.
  • ExistsAsync returns true for an existing key, false for a new one, and ignores expired keys when TimeToLive is set.
  • StoreAsync uses INSERT OR IGNORE and does not throw on duplicates.
  • Both AddSQLiteIdempotencyStore overloads register IIdempotencyStore as Scoped.
  • Unit tests cover: key exists, key absent, TTL expiry, duplicate insert, options wiring.

Dependencies

Metadata

Metadata

Labels

type:featureIndicates a new feature or enhancement to be added.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions