lib/sidekiq_unique_jobs/lua/lock.lua in sidekiq-unique-jobs-7.1.25 vs lib/sidekiq_unique_jobs/lua/lock.lua in sidekiq-unique-jobs-7.1.26
- old
+ new
@@ -1,13 +1,14 @@
-------- BEGIN keys ---------
-local digest = KEYS[1]
-local queued = KEYS[2]
-local primed = KEYS[3]
-local locked = KEYS[4]
-local info = KEYS[5]
-local changelog = KEYS[6]
-local digests = KEYS[7]
+local digest = KEYS[1]
+local queued = KEYS[2]
+local primed = KEYS[3]
+local locked = KEYS[4]
+local info = KEYS[5]
+local changelog = KEYS[6]
+local digests = KEYS[7]
+local expiring_digests = KEYS[8]
-------- END keys ---------
-------- BEGIN lock arguments ---------
local job_id = ARGV[1]
@@ -55,11 +56,16 @@
log_debug("Limit exceeded:", digest, "(", locked_count, "of", limit, ")")
log("Limited")
return nil
end
-log_debug("ZADD", digests, current_time, digest)
-redis.call("ZADD", digests, current_time, digest)
+if lock_type == "until_expired" and pttl and pttl > 0 then
+ log_debug("ZADD", expiring_digests, current_time + pttl, digest)
+ redis.call("ZADD", expiring_digests, current_time + pttl, digest)
+else
+ log_debug("ZADD", digests, current_time, digest)
+ redis.call("ZADD", digests, current_time, digest)
+end
log_debug("HSET", locked, job_id, current_time)
redis.call("HSET", locked, job_id, current_time)
log_debug("LREM", queued, -1, job_id)