Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix redis exists deprecation warning #335

Merged
merged 1 commit into from
May 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/sidekiq-scheduler/redis_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,13 @@ def self.get_all_schedules
#
# @return [Boolean] true if the schedules key is set, false otherwise
def self.schedule_exist?
Sidekiq.redis { |r| r.exists(:schedules) }
Sidekiq.redis do |r|
if r.respond_to?(:exists?)
r.exists?(:schedules)
else
!!r.exists(:schedules)
end
end
end

# Returns all the schedule changes for a given time range.
Expand Down
8 changes: 7 additions & 1 deletion spec/support/store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ def self.zrange(zset_key, from, to)
end

def self.exists(key)
Sidekiq.redis { |r| r.exists(key) }
Sidekiq.redis do |r|
if r.respond_to?(:exists?)
r.exists?(key)
else
!!r.exists(key)
end
end
end

def self.hexists(hash_key, field_key)
Expand Down