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.
相关问题
- Getting Redis Master address from Sentinel C#
- Configuring Redis to play nice with AppHarbor
- Why do we need Redis for running CKAN?
- Problem in deserialize redis-cache to objects in S
- wait for all promises to finish in nodejs with blu
In order to get all the keys available in redis server, you should open redis-cli and type:
KEYS *
In order to get more help please visit this page: This LinkSCAN doesn't require the client to load all the keys into memory like KEYS does. SCAN gives you an iterator you can use. I had a 1B records in my redis and I could never get enough memory to return all the keys at once.
Here is a python snippet to get all keys from the store matching a pattern and delete them:
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:UPDATE (V2.8 or greater):
SCAN
is a superior alternative toKEYS
, in the sense that it does not block the server nor does it consume significant resources. Prefer using it.