Reputation: 776
What is the default size of the local memory cache for Django. https://docs.djangoproject.com/en/1.8/ref/settings/ does not mention any. https://docs.djangoproject.com/en/1.8/topics/cache/#cache-arguments says it is 300, but the following code always returns a different value:
for i in range(0, 10000):
cache.set(i, i)
first = cache.get(0)
if first is None:
print i
break
I have seen values ranging from 150ish to 1500ish.
Thanks!
Upvotes: 3
Views: 1193
Reputation: 600051
The default cache size is 300, according to the code.
Your snippet won't tell you anything useful about the size of the cache. When the locmem cache is full, a subsequent set will cause it to evict items based solely on the modulus of their key's position in the dict, which is unpredictable. There is no attempt to evict based on LRU, FIFO or any other algorithm.
This is yet another reason not to use this backend n production.
Upvotes: 5