Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement .all() method. #674

Open
xEricL opened this issue Feb 24, 2023 · 2 comments
Open

Implement .all() method. #674

xEricL opened this issue Feb 24, 2023 · 2 comments

Comments

@xEricL
Copy link

xEricL commented Feb 24, 2023

Please implement a aiocache.Cache.all() method to get a list of all the key:value pairs in the cache.

It would be nice if we could also filter it, such as with aiocache.Cache.all(namespace='users') to retrieve a list of all key:value pairs where the keys start with users:

@padraic-shafer
Copy link
Contributor

I'm not very familiar with memcached, but a quick google search suggests that there is not a standard / reliable way to request all keys for that backend.

It looks like it would be straightforward for the redis backend: https://redis.io/commands/keys/

For the simple memory cache, a simple workaround in the meantime is...

cache_keys = [key for key in cache._cache if cache.startswith(namespace)]

@xEricL
Copy link
Author

xEricL commented Feb 24, 2023

So how would I get all keys for a Redis Cache? Forgive me, I'm still new to using aiocache.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants