Reputation: 1222
Redis Set Operation:
SADD key1 "value1 containing key1"
SADD key1 "value2 containing key1"
SADD key1 "value3 containing key1"
SMEMBERS Result : 1) "value2 containing key1" 2) "value3 containing key1" 3) "value1 containing key1"
SREM key1 "value2 containing key1" --> it works
Now i want to delete "value2 containing key1" from set, without passing whole value e.g. "value2 containing key1". Want to send only "value2"
SREM key1 "value2"
is there any way to do this ? Or any other method?
Upvotes: 0
Views: 1041
Reputation: 578
Instead of inserting into SET the full value("value1 : verylongmessage"), you can just inserting value("value1") to the set "key1".
BUT you should use another data structure, Hash to store the full content of the value1:
hash['value1'] = "value1 : verylongmessage" (in Redis, you can use HSET?)
So, if you want to delete value1 from the SET, you just delete from both the SET and the HASH.
Hope this can help you ~~~
Upvotes: 1