diff options
author | David Baker <dave@matrix.org> | 2015-04-17 13:51:10 +0100 |
---|---|---|
committer | David Baker <dave@matrix.org> | 2015-04-17 13:51:10 +0100 |
commit | cb03fafdf150cb97d494c1a12efb730e01309fb2 (patch) | |
tree | 5c6994f2ec826599984d7a621caeb889aeef4c57 /synapse/util | |
parent | Register the 3pid servlet (diff) | |
parent | Filter typing nofication events to only those rooms the requesting user is a ... (diff) | |
download | synapse-cb03fafdf150cb97d494c1a12efb730e01309fb2.tar.xz |
Merge branch 'develop' into csauth
Diffstat (limited to 'synapse/util')
-rw-r--r-- | synapse/util/expiringcache.py | 2 | ||||
-rw-r--r-- | synapse/util/lrucache.py | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/synapse/util/expiringcache.py b/synapse/util/expiringcache.py index 1c7859297a..06d1eea01b 100644 --- a/synapse/util/expiringcache.py +++ b/synapse/util/expiringcache.py @@ -65,7 +65,7 @@ class ExpiringCache(object): if self._max_len and len(self._cache.keys()) > self._max_len: sorted_entries = sorted( self._cache.items(), - key=lambda k, v: v.time, + key=lambda (k, v): v.time, ) for k, _ in sorted_entries[self._max_len:]: diff --git a/synapse/util/lrucache.py b/synapse/util/lrucache.py index 65d5792907..2f7b615f78 100644 --- a/synapse/util/lrucache.py +++ b/synapse/util/lrucache.py @@ -90,12 +90,16 @@ class LruCache(object): def cache_len(): return len(cache) + def cache_contains(key): + return key in cache + self.sentinel = object() self.get = cache_get self.set = cache_set self.setdefault = cache_set_default self.pop = cache_pop self.len = cache_len + self.contains = cache_contains def __getitem__(self, key): result = self.get(key, self.sentinel) @@ -114,3 +118,6 @@ class LruCache(object): def __len__(self): return self.len() + + def __contains__(self, key): + return self.contains(key) |