Skip to content

How I delete cache by key? #33

Open
@Iazzetta

Description

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions