diff --git a/CHANGELOG.md b/CHANGELOG.md index 55c9cfa2c..7f4c4a20a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Unreleased -* Fix `zpopmax` and `zpopmin` when called inside a pipeline. See #1055. +* Deprecate `Redis.current`. * Deprecate calling commands on `Redis` inside `Redis#pipelined`. See #1059. ```ruby redis.pipelined do @@ -16,6 +16,9 @@ end ``` * Deprecate `Redis#queue` and `Redis#commit`. See #1059. + +* Fix `zpopmax` and `zpopmin` when called inside a pipeline. See #1055. + * Add `Redis.silence_deprecations=` to turn off deprecation warnings. If you don't wish to see warnings yet, you can set `Redis.silence_deprecations = false`. It is however heavily recommended to fix them instead when possible. diff --git a/lib/redis.rb b/lib/redis.rb index 7df76293a..f6c1933c7 100644 --- a/lib/redis.rb +++ b/lib/redis.rb @@ -28,11 +28,15 @@ def deprecate!(message) ::Kernel.warn(message) unless silence_deprecations end - attr_writer :current - end + def current + deprecate!("`Redis.current=` is deprecated and will be removed in 5.0. (called from: #{caller(1, 1).first})") + @current ||= Redis.new + end - def self.current - @current ||= Redis.new + def current=(redis) + deprecate!("`Redis.current=` is deprecated and will be removed in 5.0. (called from: #{caller(1, 1).first})") + @current = redis + end end include Commands