Do you *need* to get the result of your query in a single call? Can you make multiple calls and paginate over the ZSET? Would it be okay if your query failed on occasion if the item was executed while you were searching?
If the answers to those questions are "no", "yes", and "yes", respectively, you can change your Lua script to not block everything else running against Redis, but it may take longer to answer your query, and it may be incorrect on occasion (because what you were searching for was already executed).
That said, I did notice at least a pair of race conditions in Sidekiq that could result in queue items being executed multiple times.
- Josiah