From a80dbecf935ae467e94ea3619e44c6a1eaa1488f Mon Sep 17 00:00:00 2001 From: CahidArda Date: Wed, 9 Sep 2026 14:32:47 +0300 Subject: [PATCH 1/2] feat: add key based locking to lua scripts --- src/lock.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lock.ts b/src/lock.ts index 6613052..39e4a2e 100644 --- a/src/lock.ts +++ b/src/lock.ts @@ -131,6 +131,7 @@ export class Lock implements AsyncDisposable { } const script = ` + #!lua flags=allow-key-locking -- Check if the current UUID still holds the lock if redis.call("get", KEYS[1]) == ARGV[1] then return redis.call("del", KEYS[1]) @@ -157,6 +158,7 @@ export class Lock implements AsyncDisposable { } const script = ` + #!lua flags=allow-key-locking -- Check if the current UUID still holds the lock if redis.call("get", KEYS[1]) ~= ARGV[1] then return 0 From 1a423a42467d7e325607b08225c02a37da69a768 Mon Sep 17 00:00:00 2001 From: CahidArda Date: Wed, 9 Sep 2026 14:50:42 +0300 Subject: [PATCH 2/2] fix: rm new lie before config --- src/lock.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/lock.ts b/src/lock.ts index 39e4a2e..4535510 100644 --- a/src/lock.ts +++ b/src/lock.ts @@ -130,8 +130,7 @@ export class Lock implements AsyncDisposable { return false; } - const script = ` - #!lua flags=allow-key-locking + const script = `#!lua flags=allow-key-locking -- Check if the current UUID still holds the lock if redis.call("get", KEYS[1]) == ARGV[1] then return redis.call("del", KEYS[1]) @@ -157,8 +156,7 @@ export class Lock implements AsyncDisposable { return false; } - const script = ` - #!lua flags=allow-key-locking + const script = `#!lua flags=allow-key-locking -- Check if the current UUID still holds the lock if redis.call("get", KEYS[1]) ~= ARGV[1] then return 0