Understand the Redis command lifecycle for unique jobs
mainThe current optimized implementation of sidekiq-unique-jobs achieves a minimum of 8 Redis commands per lock cycle. This breakdown represents the structural minimum required to maintain compatibility with the middleware ecosystem and the reaper/UI components.
Lock Phase (queue_and_lock.lua - 5 commands)
evalsha: Executes the atomic Lua script.HLEN locked: Checks if the lock limit has been reached.SET digest job_id: Creates the digest key (required by middleware).ZADD digests score digest: Registers the digest in the sorted set (required by the reaper/web UI).HSET locked job_id time: Acquires the actual lock.
Unlock Phase (unlock.lua - 3 commands)
evalsha: Executes the atomic Lua script.UNLINK digest info locked primed: Deletes all associated lock keys in a single batch command.ZREM digests digest: Removes the digest from the sorted set.