From e093c1b0f9cece3da8eca0e03a4240f64f6ccb7c Mon Sep 17 00:00:00 2001 From: Heinrich Lee Yu Date: Wed, 24 Nov 2021 01:13:20 +0800 Subject: [PATCH] Fix deprecation warning when using redis-namespace (#5066) We need to call the `script` command on the raw redis connection because passthrough for administrative commands has been deprecated and will be removed in redis-namespace 2.0 Co-authored-by: Heinrich Lee Yu --- lib/sidekiq/scheduled.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/sidekiq/scheduled.rb b/lib/sidekiq/scheduled.rb index e3537b1b..761dab5d 100644 --- a/lib/sidekiq/scheduled.rb +++ b/lib/sidekiq/scheduled.rb @@ -47,7 +47,10 @@ module Sidekiq private def zpopbyscore(conn, keys: nil, argv: nil) - @lua_zpopbyscore_sha = conn.script(:load, LUA_ZPOPBYSCORE) if @lua_zpopbyscore_sha.nil? + if @lua_zpopbyscore_sha.nil? + raw_conn = conn.respond_to?(:redis) ? conn.redis : conn + @lua_zpopbyscore_sha = raw_conn.script(:load, LUA_ZPOPBYSCORE) + end conn.evalsha(@lua_zpopbyscore_sha, keys: keys, argv: argv) rescue Redis::CommandError => e