Use Redis#exists? to fix deprecation warning#7
Open
dferrazm wants to merge 1 commit intoHouseTrip:masterfrom
Open
Use Redis#exists? to fix deprecation warning#7dferrazm wants to merge 1 commit intoHouseTrip:masterfrom
dferrazm wants to merge 1 commit intoHouseTrip:masterfrom
Conversation
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.
m-k
approved these changes
Mar 26, 2021
|
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)) |
|
Any news ? ping @mrship ? |
|
@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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When using redis-rb 4+: