How to remove redis zset?
10,614
Solution 1
You can use DEL command to remove any key from redis database, regardless of the datatype associated with it.
DEL key [key ...]
Removes the specified keys. A key is ignored if it does not exist.
Solution 2
DEL
will allow you to remove the key entirely: http://redis.io/commands/del.
ZREM
will allow you to remove members from the set: http://redis.io/commands/zrem.
There are additional ZREM*
commands that allow the removal of ranges of members - see ZREMRANGEBYLEX
, ZREMRANGEBYRANK
and ZREMRANGEBYSCORE
Solution 3
You use the "del" command to remove an entry from redis:
del test
See: http://redis.io/commands/del
Author by
xina1i
Updated on June 04, 2022Comments
-
xina1i almost 2 years
I have key "test", the type is zset, I want to remove it.Its value is complex.
127.0.0.1:6379>zrange test 1 2 1) "\x80\x02}q\x01(U\x04bodyq\x02U\x00U\t_encodingq\x03U\x05utf-8q\x04U\acookiesq\x05}q\x06U\x04metaq\a}q\bU\x05depthq\tK\x01sU\aheadersq\n}q\x0bU\aRefererq\x0c]q\rU.http://guba.eastmoney.com/list,002273,f_1.htmlq\x0easU\x03urlq\x0fX0\x00\x00\x00http://guba.eastmoney.com/list,002273,f_334.htmlU\x0bdont_filterq\x10\x89U\bpriorityq\x11K\x00U\bcallbackq\x12U\x05parseq\x13U\x06methodq\x14U\x03GETq\x15U\aerrbackq\x16Nu." 2) "\x80\x02}q\x01(U\x04bodyq\x02U\x00U\t_encodingq\x03U\x05utf-8q\x04U\acookiesq\x05}q\x06U\x04metaq\a}q\bU\x05depthq\tK\x01sU\aheadersq\n}q\x0bU\aRefererq\x0c]q\rU.http://guba.eastmoney.com/list,002273,f_1.htmlq\x0easU\x03urlq\x0fX0\x00\x00\x00http://guba.eastmoney.com/list,002273,f_335.htmlU\x0bdont_filterq\x10\x89U\bpriorityq\x11K\x00U\bcallbackq\x12U\x05parseq\x13U\x06methodq\x14U\x03GETq\x15U\aerrbackq\x16Nu." 127.0.0.1:6379>zcard test 57232
There are so many values, I want to remove them all or some. How can I do this?