Skip to content

Commit

Permalink
[extend_lock_ttl] updates
Browse files Browse the repository at this point in the history
  • Loading branch information
0exp committed Mar 30, 2024
1 parent 2189d90 commit f646550
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/redis_queued_locks/acquier/extend_lock_ttl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module RedisQueuedLocks::Acquier::ExtendLockTTL
#
# @api private
# @since 0.1.0
EXTEND_LOCK_PTTL = <<~LUA_SCRIPT.strip.tr("\n", "")
EXTEND_LOCK_PTTL = <<~LUA_SCRIPT.strip.tr("\n", '').freeze
local new_lock_pttl = redis.call("PTTL", KEYS[1]) + ARGV[1];
return redis.call("PEXPIRE", KEYS[1], new_lock_pttl);
LUA_SCRIPT
Expand All @@ -25,6 +25,7 @@ def extend_lock_ttl(redis_client, lock_name, milliseconds)

# NOTE: EVAL signature -> <lua script>, (keys number), *(keys), *(arguments)
result = redis_client.call('EVAL', EXTEND_LOCK_PTTL, 1, lock_key, milliseconds)
# TODO: upload scripts to the redis

if result == 1
RedisQueuedLocks::Data[ok: true, result: :ttl_extended]
Expand Down

0 comments on commit f646550

Please sign in to comment.