Skip to content

Commit a72cf4b

Browse files
committed
Include expected resource keys format on README.md
1 parent 5138813 commit a72cf4b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,10 @@ The `using` method wraps and executes a routine in the context of an auto-extend
6666

6767
The first parameter is an array of resources to lock; the second is the requested lock duration in milliseconds, which MUST NOT contain values after the decimal.
6868

69+
The resource keys must follow the convention `key:value`, where `key` is a unique identifier for the resource and `value` is the value of the resource. For example, if you are doing a lock based on a user's account id, you might use `account:123` as the resource key.
70+
6971
```ts
70-
await redlock.using([senderId, recipientId], 5000, async (signal) => {
72+
await redlock.using([`senderId:${senderId}`, `recipientId:${recipientId}`], 5000, async (signal) => {
7173
// Do something...
7274
await something();
7375

@@ -85,7 +87,7 @@ Alternatively, locks can be acquired and released directly:
8587

8688
```ts
8789
// Acquire a lock.
88-
let lock = await redlock.acquire(["a"], 5000);
90+
let lock = await redlock.acquire(["resource-key:resource-value"], 5000);
8991
try {
9092
// Do something...
9193
await something();

0 commit comments

Comments
 (0)