RedisLockStore
Defined in: src/redis.ts:85
LockStore on a single Redis primary (no Redlock): lease = SET NX PX, fencing token = INCR of a per-key counter.
The counter never expires (it must only grow), so one small key per lock key is kept forever.
Caveats: Redis replication is async, so after a failover a lease (or counter increments) can be lost: two holders,
or a repeated fencing token. For tokens to survive restarts, run with AOF (appendfsync everysec or always).
The protected resource should still reject writes whose token is below the highest it has seen.
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new RedisLockStore(
options):RedisLockStore
Defined in: src/redis.ts:89
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”RedisLockStore
Methods
Section titled “Methods”acquire()
Section titled “acquire()”acquire(
key,owner,ttlMs):Promise<{fencingToken:number; } |undefined>
Defined in: src/redis.ts:100
Parameters
Section titled “Parameters”string
string
number
Returns
Section titled “Returns”Promise<{ fencingToken: number; } | undefined>
Implementation of
Section titled “Implementation of”release()
Section titled “release()”release(
key,owner):Promise<void>
Defined in: src/redis.ts:109
Parameters
Section titled “Parameters”string
string
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”renew()
Section titled “renew()”renew(
key,owner,ttlMs):Promise<boolean>
Defined in: src/redis.ts:105
Parameters
Section titled “Parameters”string
string
number
Returns
Section titled “Returns”Promise<boolean>