Reputation: 39
Redis has the following data:
key value
code1 num1
code2 num2
...
code6000000 num6000000
I have a known fixed list which is not regular:
{code1, code3, code11, ..., code1234567}
How should I design Redis so that I can easily delete these kv?
Upvotes: 1
Views: 78
Reputation: 98
if you want to delete some keys that are stored in a Redis list, you can use this one line shell script in Linux:
> redis-cli LRANGE mylist 0 -1 | xargs redis-cli DEL
Upvotes: 1
Reputation: 521
Redis has a data structure like hash table this.
you can easily follow instructions there to accomplish your needs.
Example:
redis:6379> HSET myhash field1 "Hello"
(integer) 1
redis:6379> HGET myhash field1
"Hello"
redis:6379> HDEL myhash field1
(integer) 1
Upvotes: 3