Skip to content

How I delete cache by key? #33

Open
@Iazzetta

Description

@Iazzetta

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

Metadata

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