diff options
author | Erik Johnston <erik@matrix.org> | 2015-05-22 16:10:42 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2015-05-22 16:10:42 +0100 |
commit | 74b7de83ece889e585878c9974070e85a08d1a49 (patch) | |
tree | 318942c37864d8e8683739ab83ac68f7b99c922c /synapse/util | |
parent | Actually return something from lambda (diff) | |
parent | Merge pull request #156 from matrix-org/erikj/join_perf (diff) | |
download | synapse-74b7de83ece889e585878c9974070e85a08d1a49.tar.xz |
Merge branch 'develop' of github.com:matrix-org/synapse into erikj/backfill_fixes
Diffstat (limited to 'synapse/util')
-rw-r--r-- | synapse/util/lrucache.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/synapse/util/lrucache.py b/synapse/util/lrucache.py index 96163c90f1..cacd7e45fa 100644 --- a/synapse/util/lrucache.py +++ b/synapse/util/lrucache.py @@ -20,7 +20,6 @@ import threading class LruCache(object): """Least-recently-used cache.""" - # TODO(mjark) Add mutex for linked list for thread safety. def __init__(self, max_size): cache = {} list_root = [] @@ -106,6 +105,12 @@ class LruCache(object): return default @synchronized + def cache_clear(): + list_root[NEXT] = list_root + list_root[PREV] = list_root + cache.clear() + + @synchronized def cache_len(): return len(cache) @@ -120,6 +125,7 @@ class LruCache(object): self.pop = cache_pop self.len = cache_len self.contains = cache_contains + self.clear = cache_clear def __getitem__(self, key): result = self.get(key, self.sentinel) |