Get list of Cache Keys in Django

前端 未结 8 2084
暗喜
暗喜 2020-12-15 17:28

I\'m trying to understand how Django is setting keys for my views. I\'m wondering if there\'s a way to just get all the saved keys from Memcached. something like a cac

8条回答
  •  心在旅途
    2020-12-15 17:53

    Switch to using LocMemCache instead of MemcachedCache:

    CACHES = {
        'default': {
            'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
            'LOCATION': 'unique-snowflake',
        }
    }
    

    Then see the question Contents of locmem cache in Django?:

    from django.core.cache.backends import locmem
    print(locmem._caches)
    

提交回复
热议问题