Reputation: 17894
I would like to know if there is a way to inspect the content stored in the local memory cache from Django shell.
I found this answer: Contents of locmem cache in django?
But it did not work. This is what I have tried so far:
python manage.py shell
>>> from django.core.cache import caches
>>> caches.all()
[]
I found the wonderful plugin: Django debug toolbar. I can verify from the debug panel that the cache I created did exist and it has content in it.
I just want to know how to look at the cached content from Django shell.
Thanks!
Here is how I defined my local memory cache:
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
'LOCATION': 'question_cache',
'TIMEOUT': 60 * 60, # 60 secs * 60 mins
'OPTIONS': {
'MAX_ENTRIES': 100
},
}
}
Upvotes: 2
Views: 1738
Reputation: 599550
Are you asking how you can inspect the cache in your running server from the shell?
Well, there's a reason why it's called the local memory cache. That's because it's local, in other words it's not shared between processes. There's absolutely no way to get access to it from a different process.
If you want a cache that you can access from a different process, you should use one of the other cache backends. To be honest, you should be doing that anyway; locmem is really only for development.
Upvotes: 4