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
Support variadic exists and exists? #171
Conversation
redis-rb 4.2.0 made `exists` variadic and introduced `exists?`
Missed #169 but the tests could be merged. |
Any chance we can get this merged and a new version released soon? |
Ping @rafaelfranca |
Ok for
But what about:
Edit: |
Any idea on the ETA for this? |
Seems this gem isn't being actively maintained anymore :( |
fwiw, this is my patch in a Rails initializer require 'redis/namespace'
if Redis::Namespace::NAMESPACED_COMMANDS.key?("exists?")
raise "Redis::Namespace now supports variadac exists, yay!"
else
# https://github.com/resque/redis-namespace/pull/171/files
Redis::Namespace::NAMESPACED_COMMANDS["exists?"] = [ :all ]
Redis::Namespace::COMMANDS["exists?"] = [ :all ]
end |
@bf4 Does this workaround work for you? I added # config/initializers/0_redis_namespace.rb
require 'redis/namespace'
if Redis::Namespace::NAMESPACED_COMMANDS.key?("exists?")
raise "Redis::Namespace now supports variadac exists, yay!"
else
# https://github.com/resque/redis-namespace/pull/171/files
Redis::Namespace::NAMESPACED_COMMANDS["exists?"] = [ :all ]
Redis::Namespace::COMMANDS["exists?"] = [ :all ]
end This is how I use Redis::Namespace # config/initializers/redis.rb
redis_connection = Redis.new(url: Secret.sidekiq_redis_url, timeout: 5)
namespace = "#{Secret.app_namespace}:#{Rails.env}:web"
REDIS_WEB = Redis::Namespace.new(namespace, redis: redis_connection) when I open rails console I get error
And when starting sidekiq then I get stack level too deep as well :/
I tried to use code from this PR directly in my app and it works fine # Gemfile
gem 'redis-namespace', github: 'Tolsto/redis-namespace', branch: 'feature/new-exists-api' |
@ArturT class Redis::Namespace
MY_HACKY_COMMANDS = {
'exists' => [:all],
'exists?' => [:all]
}
NAMESPACED_COMMANDS.reverse_merge! MY_HACKY_COMMANDS
COMMANDS.reverse_merge! MY_HACKY_COMMANDS
MY_HACKY_COMMANDS.keys.each do |command|
next if method_defined?(command)
define_method(command) do |*args, &block|
call_with_namespace(command, *args, &block)
end
end
end |
@al Thank you! It works. I added an exception when a new redis-namespace gem version will be released. # config/initializers/redis.rb
# start of workaround
# https://github.com/resque/redis-namespace/pull/171#issuecomment-670917998
if Redis::Namespace::NAMESPACED_COMMANDS.key?("exists?")
raise "Redis::Namespace now supports variadac exists, you can remove below workaround!"
end
class Redis::Namespace
MY_HACKY_COMMANDS = {
'exists' => [:all],
'exists?' => [:all]
}
NAMESPACED_COMMANDS.reverse_merge!(MY_HACKY_COMMANDS)
COMMANDS.reverse_merge!(MY_HACKY_COMMANDS)
MY_HACKY_COMMANDS.keys.each do |command|
next if method_defined?(command)
define_method(command) do |*args, &block|
call_with_namespace(command, *args, &block)
end
end
end
# end of workaround |
#169 was merged, this can be closed now. |
Can someone grant similar workaround for |
Not sure I follow. I don't see a |
I'm talking about the second warning in this comment while running Sidekiq, I got the same: |
redis-rb 4.2.0 made
exists
variadic and introducedexists?