Clock used to evaluate lock TTL expiry.
Attempts to acquire the lock named key.
The lock name.
Lifetime of the lock in milliseconds; after this it expires and may be acquired by others.
A unique fencing token to pass to release on success, or null if the lock is currently held.
Releases a lock previously acquired with acquire.
The lock name.
The token returned by the matching acquire call.
In-process Lock backed by a
Map, with TTL expiry evaluated via an injected Clock.Remarks
Provides real mutual exclusion within a single process. An expired lock is treated as free on the next acquisition attempt. Not suitable for coordinating across processes or hosts.
Example