Skip to content

Commit

Permalink
Don't use depicated Redis commands
Browse files Browse the repository at this point in the history
Sidekiq 7.1 now warns on depircated Redis commands. `zrangebyscore` is currently used by the gem which is depicated in Redis 6.2 which is the mimimum required Redis version for current Sidekiq.

Since we most likely are supporting the latest 7.x of Sidekiq, I reused the "GTE 7.0" check and redirected calls to `zrangebyscore` to use the Sidekiq Adaptor class.

The difference in commands is based off of the changes to Sidekiq when it swapped out the depricated call:
sidekiq/sidekiq@1aca434#diff-25f829140be25a886134933b537d356dddb12234ca85319e50b381f9edb6b74dR686
  • Loading branch information
t27duck authored and marcelolx committed May 4, 2023
1 parent 91adde9 commit 6e5c097
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/sidekiq-scheduler/redis_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def self.schedule_exist?
#
# @return [Array] array with all the changed job names
def self.get_schedule_changes(from, to)
Sidekiq.redis { |r| r.zrangebyscore(schedules_changed_key, from, "(#{to}") }
SidekiqScheduler::SidekiqAdapter.redis_zrangebyscore(schedules_changed_key, from, "(#{to}")
end

# Register a schedule change for a given job
Expand Down
10 changes: 10 additions & 0 deletions lib/sidekiq-scheduler/sidekiq_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,15 @@ def self.redis_key_exists?(key_name)
end
end
end

def self.redis_zrangebyscore(key, from, to)
Sidekiq.redis do |r|
if SIDEKIQ_GTE_7_0_0
r.zrange(key, from, to, "BYSCORE")
else
r.zrangebyscore(key, from, to)
end
end
end
end
end
2 changes: 1 addition & 1 deletion spec/support/store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def self.zadd(sorted_set_key, score, field_key)
end

def self.zrangebyscore(zset_key, from, to)
Sidekiq.redis { |r| r.zrangebyscore(zset_key, from, to) }
SidekiqScheduler::SidekiqAdapter.redis_zrangebyscore(zset_key, from, to)
end

def self.zrange(zset_key, from, to)
Expand Down

0 comments on commit 6e5c097

Please sign in to comment.