Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django cache loses keys

I have a Django installation that uses the FileSystem caches. The caching system is used by an array of different views. Putting in place various logs to log when a key is not found in the cache and hence regenerated, I've found out that often the keys are lost. I don't have any "cache delete" in place and all the keys are stored to last 24 hours, but in the logs they all appear to be regenerated once in a while.

Is there any hidden parameter like "don't store more than n keys" or "more than n megabytes of data" or something? I'm a bit lost because it just seems that the keys are lost and I don't know when and why.

Also, I originally chose as cache location "/tmp/django-cache", so I thought that maybe the tmp directory was being cleaned by Linux, but changing the location to a "safer" one in my home directory doesn't change the anomaly.

Also, the full cache directory is around 25Mb, so I don't think there is something cleaning it up because it's too big.

Any idea?

like image 411
pistacchio Avatar asked Jul 30 '26 00:07

pistacchio


1 Answers

The maximum number of items allowed in the cache before old values are deleted for locmem, filesystem and database backends is 300. You can change it by setting OPTIONS > MAX_ENTRIES.

From the Django documentation:

MAX_ENTRIES: The maximum number of entries allowed in the cache before old values are deleted. This argument defaults to 300.

like image 73
Selcuk Avatar answered Aug 01 '26 15:08

Selcuk