resque / redis-namespace

This gem adds a Redis::Namespace class which can be used to namespace Redis keys.
http://redis.io
MIT License
695 stars 192 forks source link

`srem?` doesn't have effect on set #226

Closed eggplants closed 1 year ago

eggplants commented 1 year ago

Both sadd and sadd? adds a value into a set. But I'm confused that srem? doesn't remove a value like srem. Is it correct?

RUBY_VERSION #=> "3.0.6"
Redis::VERSION #=> "4.8.1"
Redis::Namespace::VERSION #=> "1.10.0"

require "redis-namespace"
redis_connection = Redis.new(host: ENV["REDIS_HOST"], port: ENV["REDIS_PORT"])
redis = Redis::Namespace.new("Rspec Instance", redis: redis_connection)

set_key = "foo:bar"

redis.smembers set_key #=> []

redis.sadd set_key, 1 #=> true
redis.sadd? set_key, 2 #=> true
$redis.smembers set_key #=> ["1", "2"]

redis.srem set_key, 1 #=> true
redis.srem? set_key, 2 #=> false
$redis.smembers set_key #=> ["2"]

$redis.srem set_key, 2 #=> true
$redis.smembers set_key #=> []
eggplants commented 1 year ago

It has already fixed in #224 and v1.11.0. After updating my issue was fixed.