Reputation: 2834
I am trying to cache a class based view like so
urls.py
from django.views.decorators.cache import cache_page
from django.conf.urls import url
urlpatterns = [
url(r'^/awesome-url$', cache_page(60 * 60)(TemplateView.as_view(template_name="awesome.html")), name="awesome"),
]
settings.py
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
'LOCATION': 'unique-snowflake'
}
}
My hope was to have my views cached and I wanted to verify that this was happening by inspecting it with:
from django.core.cache.backends import locmem
print locmem._caches
>{}
Source: Contents of locmem cache in django?
Sadly the backend is empty. So I am doubtful that the view is being cached, can anyone help?
Upvotes: 2
Views: 1179
Reputation: 599540
As I said in that linked answer, the LocMem cache really is what the name describes: a local memory cache. It's just a global variable inside each process, which is only accessible inside that process.
There's no way for a command in the shell to access the contents of the local memory cache running in the server.
Use a different cache backend, or print the cache values from inside your views.
Upvotes: 1