repoze/repoze.lru — Issue #7: LRUCache.put() can take multiple seconds on large caches
Author: snordhausen
Created: 2012-01-13 13:27:04+00:00
State: open

When put() looks for a place to store a new entry, the worst case situation is that all entries in the cache have ref==True. In this case put() walks through the entire cache, setting everything to ref==False. For a cache with 10 million entries, this process takes 3.6 seconds on my machine. It is very, very undesirable to have an application hang for this amount of time.

How to reproduce in Python shell:

>>> cache = LRUCache(10**7)
>>> for i in xrange(10**7):
... cache.put(i, i)
...
>>> cache.put("foo", "bar") # <---- takes multiple seconds.