One Durable Object per lock key, and a Durable Object executes one request at
a time — which is what makes the read-compare-write below atomic without a
transaction, and what makes this a genuine distributed lock rather than a
best-effort one.
The holder record lives in state.storage, never in a field. A Durable
Object is evicted after 70–140 seconds of inactivity when it cannot
hibernate, and a lock TTL routinely outlives that; a deadline held in memory
would evaporate on eviction and hand the same lock to a second holder, which
is precisely the failure a distributed lock exists to prevent.
Serializes lock acquisition for one key.
One Durable Object per lock key, and a Durable Object executes one request at a time — which is what makes the read-compare-write below atomic without a transaction, and what makes this a genuine distributed lock rather than a best-effort one.
The holder record lives in
state.storage, never in a field. A Durable Object is evicted after 70–140 seconds of inactivity when it cannot hibernate, and a lock TTL routinely outlives that; a deadline held in memory would evaporate on eviction and hand the same lock to a second holder, which is precisely the failure a distributed lock exists to prevent.Example
Since
0.2.0