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

How I delete cache by key? #33

Open
Iazzetta opened this issue Apr 6, 2021 · 0 comments
Open

How I delete cache by key? #33

Iazzetta opened this issue Apr 6, 2021 · 0 comments

Comments

@Iazzetta
Copy link

Iazzetta commented Apr 6, 2021

When I add the django elasticache and connect, works but I can't delete using my old function.

def delete_cache(text):
    for key in list(cache._cache.keys()):
        if text in key:
            cache.delete(key.replace(':1:', ''))

Usage

cache.set('test_123', data, 10000)
cache.set('test_4321', data, 10000)
cache.set('test', data, 10000)

# delete all cache starting by key "test"
delete_cache('test')

But using memcache I got this:

File "/var/app/current/xxx/utils.py", line x, in delete_cache
for key in list(cache._cache.keys()):

AttributeError: 'Client' object has no attribute 'keys'

How do I list Memcached keys?
Thanks

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

1 participant