Skip to content

srem? doesn't have effect on set #226

Closed
@eggplants

Description

@eggplants

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 #=> []

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions