moneta-rb / moneta

a unified interface to key/value stores
https://github.com/moneta-rb/moneta
MIT License
1.11k stars 87 forks source link

Fix deprecation warnings for redis 4.6+ multi/pipelined handling #214

Closed sriedel closed 2 years ago

sriedel commented 2 years ago

As of version 4.6 of the redis gem, the following deprecation warning is emitted:

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 [...]/gems/moneta-1.4.2/lib/moneta/adapters/redis.rb:157:in `with_expiry_update'}

This PR silences those expirations by passing a "pipeline handle", which uses the new block parameter mentioned in the deprecation message and falling back to the regular @backend variable as used before, if no block parameter is present.

The specs for the redis handler are green for me with redis version 4.5.1 and 4.6.0; not sure how this should be handled in the unit tests (if at all).

asppsa commented 2 years ago

Thanks for this! Looks good to me - I'll run the test gauntlet over it and get this merged :+1:

micke commented 2 years ago

Thank you @asppsa, will we get a release cut for this today?

asppsa commented 2 years ago

@micke will do my best!

asppsa commented 2 years ago

v1.5.0 now cut

micke commented 2 years ago

Thank you both!