CacheLock
Esta página aún no está disponible en tu idioma.
Defined in: src/cache/CacheLock.ts:15
A held mutual-exclusion lock, handed out by acquireLock.
Exists so that “release” can mean release what I took rather than
delete this key. The two differ the moment a holder overruns its
TTL: the entry it wrote is gone, someone else has written their own,
and a bare cache.delete(key) at that point silently evicts the new
owner’s lock while they are still inside the critical section. The
token pins the identity that makes the difference checkable.
Properties
Section titled “Properties”
readonlykey:string
Defined in: src/cache/CacheLock.ts:17
The cache key this lock occupies.
readonlytoken:string
Defined in: src/cache/CacheLock.ts:24
The random value written under key — the proof of ownership that release checks. Exposed because a caller that also writes a fencing token into the resource it is guarding needs the same value on both sides.
Methods
Section titled “Methods”release()
Section titled “release()”release():
Promise<boolean>
Defined in: src/cache/CacheLock.ts:40
Release the lock, but only while it is still ours.
Returns true when our token was still in place and the delete was
issued; false when the lock had already lapsed — its TTL expired
and either nobody or somebody else now holds the key. A false
return is worth acting on: it says the critical section ran longer
than its TTL, so another holder may have been running concurrently
and whatever this one just did was not, in fact, exclusive.
Idempotent — a second call finds no matching token and returns
false. Best-effort in the same sense as Cache.delete, which
swallows transient backend errors; true means “still ours, delete
issued”, not “delete confirmed durable”.
Returns
Section titled “Returns”Promise<boolean>
