Change LRUCache to be tree-based so we can delete subtrees.

This commit is contained in:
David Baker 2016-01-21 19:16:25 +00:00
parent 297eded261
commit f1f8122120
7 changed files with 140 additions and 52 deletions

View file

@ -309,14 +309,14 @@ def _flatten_dict(d, prefix=[], result={}):
return result
regex_cache = LruCache(5000)
regex_cache = LruCache(5000, 1)
def _compile_regex(regex_str):
r = regex_cache.get(regex_str, None)
r = regex_cache.get((regex_str,), None)
if r:
return r
r = re.compile(regex_str, flags=re.IGNORECASE)
regex_cache[regex_str] = r
regex_cache[(regex_str,)] = r
return r