Reputation: 2451
I'm working on Cloud Memory Store (documentation) for storing data in the Redis using python client library.
Python client library has various function to add, set, get, delete values (for more info), but I couldn't find anything to get the list of values that are already been stored in the database.
My use case is to fetch a chunk of keys(based on specific prefix) and delete them.
I want to know how to get the list of keys that are already stored in the database.
Upvotes: 2
Views: 2381
Reputation: 4291
Here is a python snippet using keys()
to get all keys from the store matching a pattern and delete them one-by-one:
import redis
r = redis.Redis(host='localhost', port=6379, db=0)
for key in r.keys('*'):
# delete the key
r.delete(key)
Upvotes: 2