RedisIdempotencyStore
Defined in: packages/pipeline-idempotency/src/stores/redis.store.ts:76
IdempotencyStore backed by Redis (node-redis) — a drop-in replacement for the memory store that shares state across instances.
Atomicity comes from Redis itself: setIfAbsent issues
SET key value PX <ttl> NX, which sets the key only if it does not already
exist and returns null otherwise. Owner-aware completion and release use
Lua scripts so a stale execution cannot overwrite/delete a newer claim.
TTL is enforced by Redis, so expired keys never linger.
A stored value that is not valid JSON fails closed: get throws, and
the owner-aware writes cannot prove ownership of it, so they leave it
untouched and return false.
Example
Section titled “Example”import { createClient } from 'redis';const client = createClient({ url: process.env.REDIS_URL });await client.connect();const store = new RedisIdempotencyStore(client);Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new RedisIdempotencyStore(
client,options?):RedisIdempotencyStore
Defined in: packages/pipeline-idempotency/src/stores/redis.store.ts:79
Parameters
Section titled “Parameters”client
Section titled “client”options?
Section titled “options?”RedisIdempotencyStoreOptions = {}
Returns
Section titled “Returns”RedisIdempotencyStore
Methods
Section titled “Methods”completeIfOwned()
Section titled “completeIfOwned()”completeIfOwned(
key,claimId,record,ttlMs):Promise<boolean>
Defined in: packages/pipeline-idempotency/src/stores/redis.store.ts:104
Atomically replaces the live in_progress record with record only when
the existing record is still owned by claimId.
Parameters
Section titled “Parameters”string
claimId
Section titled “claimId”string
record
Section titled “record”number
Returns
Section titled “Returns”Promise<boolean>
true when this claim completed its own record; false when the
claim expired, was replaced, or was otherwise no longer owned by the caller.
Implementation of
Section titled “Implementation of”IdempotencyStore.completeIfOwned
delete()
Section titled “delete()”delete(
key):Promise<void>
Defined in: packages/pipeline-idempotency/src/stores/redis.store.ts:135
Unconditional delete for administrative or custom use. Pipeline failure release uses deleteIfOwned, not this method.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”deleteIfOwned()
Section titled “deleteIfOwned()”deleteIfOwned(
key,claimId):Promise<boolean>
Defined in: packages/pipeline-idempotency/src/stores/redis.store.ts:117
Atomically removes the live record only when it is still owned by
claimId. Used by releaseOnError so a stale failure cannot delete a
newer execution’s claim.
Parameters
Section titled “Parameters”string
claimId
Section titled “claimId”string
Returns
Section titled “Returns”Promise<boolean>
Implementation of
Section titled “Implementation of”IdempotencyStore.deleteIfOwned
get(
key):Promise<IdempotencyRecord|undefined>
Defined in: packages/pipeline-idempotency/src/stores/redis.store.ts:86
Returns the live (non-expired) record for key, or undefined if there is
none.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<IdempotencyRecord | undefined>
Implementation of
Section titled “Implementation of”set(
key,record,ttlMs):Promise<void>
Defined in: packages/pipeline-idempotency/src/stores/redis.store.ts:125
Unconditional overwrite for administrative or custom use. Pipeline execution completion uses completeIfOwned, not this method.
Parameters
Section titled “Parameters”string
record
Section titled “record”number
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”setIfAbsent()
Section titled “setIfAbsent()”setIfAbsent(
key,record,ttlMs):Promise<boolean>
Defined in: packages/pipeline-idempotency/src/stores/redis.store.ts:91
Atomically stores record only if no live record exists for key.
Parameters
Section titled “Parameters”string
record
Section titled “record”number
Returns
Section titled “Returns”Promise<boolean>
true if the key was claimed by this call, false if a live
record already existed.