Skip to content

Comments

Use Redis#exists? to fix deprecation warning#7

Open
dferrazm wants to merge 1 commit intoHouseTrip:masterfrom
dferrazm:fix-deprecation-warning-from-redis
Open

Use Redis#exists? to fix deprecation warning#7
dferrazm wants to merge 1 commit intoHouseTrip:masterfrom
dferrazm:fix-deprecation-warning-from-redis

Conversation

@dferrazm
Copy link

@dferrazm dferrazm commented Dec 4, 2020

When using redis-rb 4+:

Redis#exists(key)` will return an Integer in redis-rb 4.3. `exists?` returns a boolean, you should use it instead.

When using redis-rb 4+:
Redis#exists(key)` will return an Integer in redis-rb 4.3. `exists?` returns a boolean, you should use it instead.
@latortuga
Copy link

Ran into this same thing and just monkeypatched it myself in an initializer:

# Patch remote_lock/adapters/redis.rb to use #exists? instead of deprecated
# #exists.
class RemoteLock::Adapters::Redis
  def store(key, expires_in_seconds)
    @connection.watch(key)

    have_competition = @connection.exists?(key)

    !! @connection.multi do
      break if have_competition
      @connection.setex(key, expires_in_seconds, uid)
    end
  end
end

RemoteLock.new(RemoteLock::Adapters::Redis.new(Redis.connection))

@cprodhomme
Copy link

Any news ? ping @mrship ?

@latortuga
Copy link

@cprodhomme if it's helpful at all, I ended up migrating away from this gem to https://github.com/leandromoreira/redlock-rb which appears to have slightly more maintenance activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants