Class InMemoryIdempotentRepository
In-memory implementation of .
Uses a for thread-safe deduplication.
Supports optional TTL-based eviction to prevent unbounded memory growth.
Suitable for single-process scenarios and testing.
public sealed class InMemoryIdempotentRepository : IIdempotentRepository
Inheritance
Implements
Properties
Count
Gets the current number of tracked keys (including potentially expired ones).
public int Count { get; }
Methods
Add(string, CancellationToken)
Attempts to add the key. Returns true if the key was new (not a duplicate).
public Task<bool> Add(string key, CancellationToken ct = default)
Claim(string, TimeSpan?, CancellationToken)
Claims the key as does, and when it is held already tells why: the message is still being
public Task<IdempotentClaim> Claim(string key, TimeSpan? abandonedAfter, CancellationToken ct = default)
Clear(CancellationToken)
Removes all keys from the repository.
public Task Clear(CancellationToken ct = default)
Confirm(string, CancellationToken)
Confirms the key after successful processing.
public Task Confirm(string key, CancellationToken ct = default)
Confirm(string, string?, CancellationToken)
Confirms the claim token names (from ) after successful processing. Returns
public Task<bool> Confirm(string key, string? token, CancellationToken ct = default)
Contains(string, CancellationToken)
Checks if the key already exists in the repository.
public Task<bool> Contains(string key, CancellationToken ct = default)
Lease(string, TimeSpan?, CancellationToken)
that also names the claim it took: identifies this claim of
public Task<IdempotentLease> Lease(string key, TimeSpan? abandonedAfter, CancellationToken ct = default)
Release(string, string?, CancellationToken)
Removes the claim token names (from ), so the message can be processed again.
public Task<bool> Release(string key, string? token, CancellationToken ct = default)
Remove(string, CancellationToken)
Removes the key, allowing it to be reprocessed.
public Task Remove(string key, CancellationToken ct = default)
Constructors
InMemoryIdempotentRepository(TimeSpan?)
Creates a repository with optional TTL for automatic key expiration.