Skip to content

Commit

Permalink
Merge pull request #149 from usiegj00/patch-1
Browse files Browse the repository at this point in the history
Resolve redis-rb warning exists => exists?
  • Loading branch information
mlitwiniuk authored Aug 6, 2020
2 parents f3e8ccb + c6344d7 commit 5115706
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/lit/adapters/redis_storage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,18 @@ def initialize
Lit.redis
end

# This handles a change in the redis-rb gem that changes exists => exists?
def exists?(key)
# Use recommended binary-returning method create [with this redis-rb commit](https://github.com/redis/redis-rb/commit/bf42fc9e0db4a1719d9b1ecc65aeb20425d44427).
return Lit.redis.exists?(key) if Lit.redis.respond_to?(:exists?)
# Fall back with older gem
Lit.redis.exists(key)
end

def [](key)
if Lit.redis.exists(_prefixed_key_for_array(key))
if self.exists?(_prefixed_key_for_array(key))
Lit.redis.lrange(_prefixed_key(key), 0, -1)
elsif Lit.redis.exists(_prefixed_key_for_nil(key))
elsif self.exists?(_prefixed_key_for_nil(key))
nil
else
Lit.redis.get(_prefixed_key(key))
Expand Down Expand Up @@ -56,7 +64,7 @@ def keys
end

def has_key?(key)
Lit.redis.exists(_prefixed_key(key))
self.exists?(_prefixed_key(key))
end
alias key? has_key?

Expand Down

0 comments on commit 5115706

Please sign in to comment.