Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Contents of locmem cache in Django?

I was trying to use the locmem cache for my web application but couldn't find any documentation on how to see the contents of the cache. I mean I want to check if my keys are being set correctly in the cache. How can I list all the keys in this cache or is that even possible?

I found the question "Get list of Cache Keys in Django" but it's about memcache, not the locmem cache.

like image 403
Mayank Avatar asked Nov 29 '12 16:11

Mayank


1 Answers

The thing about locmem is that it really is just a local memory storage. Looking at the code, it's clear that the data is just being saved in a module-level variable, _caches, in that module. So you can just do

from django.core.cache.backends import locmem
print(locmem._caches)
like image 159
Daniel Roseman Avatar answered Oct 01 '22 13:10

Daniel Roseman