InMemoryReplayGuard class

A bounded, in-process ReplayGuard: an LRU map from id to the digest accepted under it, its retention deadline, and the response it produced.

Suitable when one process is the sole consumer for the recipient VID it serves and losing the record on restart is acceptable.

Not suitable when the consumer is replicated: two replicas hold separate maps, so a document accepted by replica A is fresh at replica B and the effect happens twice — the exact failure item 11 exists to prevent. Replicated deployments MUST back the guard with a shared store.

Eviction is by capacity as well as by retainUntil: a burst of distinct documents can push an older record out before its deadline, and a replay arriving after that would be accepted. Size the capacity above the number of distinct documents the widest acceptance window can hold.

LinkedHashMap preserves insertion order, which is what makes the LRU a remove-then-reinsert rather than a second index. Dart is single-threaded per isolate and none of these methods await, so claim-and-record is atomic by construction.

Implemented types

Constructors

InMemoryReplayGuard([int capacity = defaultReplayCapacity])
Builds a guard retaining at most capacity records.

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
size → int
How many records are currently retained. For tests and metrics.
no setter

Methods

claim(String id, String digest, DateTime? retainUntil, DateTime now) → Future<ReplayVerdict>
Claim id for execution on behalf of a document with identity digest.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
purgeExpired(DateTime now) → void
Drop every record whose retainUntil has passed.
recordResponse(String id, Object? response) → Future<void>
Attach the response a completed execution produced, so a later duplicate can be answered with it per §7.2 (Disposition of a duplicate) rather than merely absorbed in silence.
override
release(String id, String digest) → Future<void>
Release a claim whose execution is not to stand — for example a refusal the consumer marked retryable, where §8.4 has just invited the producer to re-send the same bytes. Without this, that invited retry would come back as an absorbed duplicate carrying the same failure forever.
override
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited