Μετάβαση στο περιεχόμενο

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.

import { createClient } from 'redis';
const client = createClient({ url: process.env.REDIS_URL });
await client.connect();
const store = new RedisIdempotencyStore(client);

new RedisIdempotencyStore(client, options?): RedisIdempotencyStore

Defined in: packages/pipeline-idempotency/src/stores/redis.store.ts:79

RedisClientLike

RedisIdempotencyStoreOptions = {}

RedisIdempotencyStore

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.

string

string

IdempotencyRecord

number

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.

IdempotencyStore.completeIfOwned


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.

string

Promise<void>

IdempotencyStore.delete


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.

string

string

Promise<boolean>

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.

string

Promise<IdempotencyRecord | undefined>

IdempotencyStore.get


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.

string

IdempotencyRecord

number

Promise<void>

IdempotencyStore.set


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.

string

IdempotencyRecord

number

Promise<boolean>

true if the key was claimed by this call, false if a live record already existed.

IdempotencyStore.setIfAbsent