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

The redis client from Rails.cache.data doesn't interface correctly with sets #356

Open
alexssung opened this issue Dec 1, 2022 · 1 comment

Comments

@alexssung
Copy link

alexssung commented Dec 1, 2022

When managing redis sets using the redis client derived from Rails.cache.data, the keys associated with the created sets do not work properly for methods such as #exists #expire and #del

Example:

redis_store_client = Rails.cache.data
redis_store_client.sadd("set-test", "a")
redis_store_client.smembers("set-test")
#=> ["a"]
redis_store_client.exists("set-test")
#=> 0 (should be 1)
redis_store_client.expire("set-test", 1)
#=> false (should succeed and return true)
redis_store_client.del("set-test")
#=> 0 (should be 1)
redis_store_client.smembers("set-test")
#=> ["a"] (expire and del did not work)

# how it should work...
other_redis_client = Redis.new(host: ENV["REDIS_HOST"], port: ENV["REDIS_PORT"])
other_redis_client.sadd("set-test2", "a")
other_redis_client.smembers("set-test2")
#=> ["a"]
other_redis_client.exists("set-test2")
#=> 1
other_redis_client.expire("set-test2", 1)
#=> true
# wait 1 sec...
other_redis_client.smembers("set-test2")
#=> []
@tubbo
Copy link
Contributor

tubbo commented Feb 22, 2023

Redis::Store inherits from the Redis client directly, and i don't believe we are overriding those methods, so i think this might be better suited for the redis-rb issue tracker.

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

2 participants