alepha@docs:~/docs/packages/alepha$
cat lock.md | pretty1 min read
Last commit:
#Alepha - Lock
#Installation
Part of the alepha package. Import from alepha/lock.
npm install alepha
#Overview
Resource locking for distributed systems.
Features:
- Distributed locks with timeout
- Time-based lock expiration
- Automatic release on scope exit
- Distributed coordination via Redis
- Providers: Redis when
REDIS_URLis set, Memory otherwise
Set REDIS_URL and a lock held on one instance is held for all of them:
each $job cron tick runs on one instance. Leave it unset and locks only
exclude callers inside this process. An app's own LockProvider or
LockTopicProvider substitution wins over both.
#API Reference
#Primitives
$lock- Distributed lock middleware forusearrays in$action,$job,$page,$pipeline.
#Providers
LockProvider- Store Provider InterfaceMemoryLockProvider- A simple in-memory store provider.RedisLockProvider- Locks over RedisSET NX PX.