Skip to content

Commit

Permalink
fix: use Redis#exists? for get boolean value
Browse files Browse the repository at this point in the history
  • Loading branch information
isqad committed Aug 19, 2021
1 parent 9f22a94 commit 03eab18
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
8 changes: 0 additions & 8 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
if RUBY_VERSION < '2.4'
appraise 'rails3.2' do
gem 'rails', '~> 3.2.0'
end

appraise 'rails4.0' do
gem 'rails', '~> 4.0.13'
end

appraise 'rails4.1' do
gem 'rails', '~> 4.1.16'
end
end

appraise 'rails4.2' do
Expand Down
2 changes: 1 addition & 1 deletion lib/resque/integration/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Engine < Rails::Engine
initializer 'resque-integration.redis' do
redis = Resque.config.redis

if redis.any?
if redis.present?
Resque.redis = Redis.new(redis)
Resque.redis.namespace = redis[:namespace] if redis[:namespace]
end
Expand Down
6 changes: 5 additions & 1 deletion lib/resque/integration/unique.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,12 @@ def lock_timeout
end

# Returns true if resque job is in locked state
#
# Returns Boolean
def locked?(*args)
::Resque.redis.exists(lock_id(*args))
redis = ::Resque.redis

redis.respond_to?(:exists?) ? redis.exists?(lock_id(*args)) : redis.exists(lock_id(*args))
end

# Dequeue unique job
Expand Down
2 changes: 2 additions & 0 deletions resque-integration.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Gem::Specification.new do |gem|
gem.add_runtime_dependency 'multi_json'
gem.add_runtime_dependency 'rake'

gem.add_runtime_dependency 'redis'

gem.add_development_dependency 'bundler'
gem.add_development_dependency 'rspec', '~> 2.14'
gem.add_development_dependency 'rspec-its'
Expand Down

0 comments on commit 03eab18

Please sign in to comment.