Skip to content

Commit a651ff9

Browse files
committed
chore: fix doc about lock factory API
1 parent 41bfae1 commit a651ff9

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

docs/content/docs/api.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,10 @@ await lock.forceRelease()
151151
Create a lock.
152152

153153
```ts
154-
const lock = verrou.createLock('key')
155-
const lock = verrou.createLock('key', '5m')
156-
const lock = verrou.createLock('key', 30_000)
154+
const lockFactory = new LockFactory(redisStore())
155+
const lock1 = lockFactory.createLock('key')
156+
const lock2 = lockFactory.createLock('key', '5m')
157+
const lock3 = lockFactory.createLock('key', 30_000)
157158
```
158159

159160
First argument is the lock key. Second argument is optional and is the lock expiration time. By default, the lock expiration time is `30s`.
@@ -163,8 +164,9 @@ First argument is the lock key. Second argument is optional and is the lock expi
163164
Restore a lock. Useful when sharing a lock between multiple processes. See [Sharing a lock between multiple processes](./usage.md#sharing-a-lock-between-multiple-processes) for more details.
164165

165166
```ts
166-
const lock1 = verrou.createLock('key', 'owner')
167-
const lock2 = verrou.restoreLock(lock1.serialize())
167+
const lockFactory = new LockFactory(redisStore())
168+
const lock1 = lockFactory.createLock('key', 'owner')
169+
const lock2 = lockFactory.restoreLock(lock1.serialize())
168170
```
169171

170172
## Verrou API

0 commit comments

Comments
 (0)