redis-commands

In redis, how do i remove keys?

坚强是说给别人听的谎言 提交于 2019-11-27 10:39:59
问题 I want to remove keys that match "user*". how do I do that in redis command line? 回答1: This is not a feature right now to be able to do in one shot (see the comments in the DEL documentation). Unfortunately, you are only left with using KEYS , looping through the results, and then using DEL to remove each one. How about using bash a bit to help? for key in `echo 'KEYS user*' | redis-cli | awk '{print $1}'` do echo DEL $key done | redis-cli To step through it: echo 'KEYS user*' | redis-cli |

Redis command to get all available keys?

纵饮孤独 提交于 2019-11-26 23:46:08
问题 Is there a Redis command for fetching all keys in the database? I have seen some python-redis libraries fetching them. But was wondering if it is possible from redis-client. 回答1: Try to look at KEYS command. KEYS * will list all keys stored in redis. EDIT: please note the warning at the top of KEYS documentation page: Time complexity: O(N) with N being the number of keys in the database, under the assumption that the key names in the database and the given pattern have limited length. UPDATE