Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecation warning from Redis::List#shift #269

Open
eguchi-ken opened this issue Aug 16, 2022 · 2 comments
Open

Deprecation warning from Redis::List#shift #269

eguchi-ken opened this issue Aug 16, 2022 · 2 comments

Comments

@eguchi-ken
Copy link

problem

I used Redis::List#shift

list = Redis::List.new("test")
list.push(10)
list.push(20)

list.shift(1)

list.shift(1) is working. However, it printed following message.

Pipelining commands on a Redis instance is deprecated and will be removed in Redis 5.0.0.

redis.multi do
  redis.get("key")
end

should be replaced by

redis.multi do |pipeline|
  pipeline.get("key")
end

(called from ~/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/redis-objects-1.7.0/lib/redis/objects/connection_pool_proxy.rb:10:in `block in method_missing'}

solution

I think that following code should use pipleline instead of redis.

def shift(n=nil)
if n
result, = redis.multi do
redis.lrange(key, 0, n - 1)
redis.ltrim(key, n, -1)
end
unmarshal result
else
unmarshal redis.lpop(key)
end
end

I'll probably fix it like this.

        result, = redis.multi do |pipeline|
          pipeline.lrange(key, 0, n - 1)
          pipeline.ltrim(key, n, -1)
        end

Could you please fix it?

@matthewhively
Copy link

I believe that this issue would also apply to several other commands.
The deprecations will appear anywhere that redis.multi or redis.pipelined are called with a block without arguments.
By my quick search it looks like there are changes to be made in the following files:
lib/redis/objects/hashes.rb
lib/redis/objects/sets.rb
lib/redis/objects/lists.rb
lib/redis/list.rb
lib/redis/sorted_set.rb

@nateware
Copy link
Owner

Please try locking to version 2.0.0.beta which I just pushed to rubygems

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

No branches or pull requests

3 participants