Skip to content

Commit

Permalink
Deal with redis-rb warning for pipelined call
Browse files Browse the repository at this point in the history
redis-rb 4.6 deprecated calling `pipelined` without having the given
block accept the client and added a warning.
See https://github.com/redis/redis-rb/blob/21ec1dec064f43def1f47983431861e6491b770e/CHANGELOG.md#460
for more details.

As suggested in their changelog this adapts the call to `pipelined`
accordingly.
This behaviour was also already accepted in the older redis-rb versions,
so it is safe to make this change without limiting the redis-rb
gem versions that can be used together with gcra-ruby.
  • Loading branch information
tobischo committed Feb 12, 2022
1 parent 122a2b1 commit 277d580
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/gcra/redis_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ def initialize(redis, key_prefix, options = {})
# Returns the value of the key or nil, if it isn't in the store.
# Also returns the time from the Redis server, with microsecond precision.
def get_with_time(key)
time_response, value = @redis.pipelined do
@redis.time # returns tuple (seconds since epoch, microseconds)
@redis.get(@key_prefix + key)
time_response, value = @redis.pipelined do |pipeline|
pipeline.time # returns tuple (seconds since epoch, microseconds)
pipeline.get(@key_prefix + key)
end
# Convert tuple to nanoseconds
time = (time_response[0] * 1_000_000 + time_response[1]) * 1_000
Expand Down

0 comments on commit 277d580

Please sign in to comment.