summary refs log tree commit diff
path: root/synapse/util/caches/descriptors.py
diff options
context:
space:
mode:
Diffstat (limited to 'synapse/util/caches/descriptors.py')
-rw-r--r--synapse/util/caches/descriptors.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/synapse/util/caches/descriptors.py b/synapse/util/caches/descriptors.py

index f31dfb22b7..bf271ce5b5 100644 --- a/synapse/util/caches/descriptors.py +++ b/synapse/util/caches/descriptors.py
@@ -94,6 +94,9 @@ class Cache(object): else: return default + def has(self, key): + return key in self.cache + def update(self, sequence, key, value): self.check_thread() if self.sequence == sequence: @@ -134,6 +137,12 @@ class Cache(object): self.sequence += 1 self.cache.clear() + def __contains__(self, key): + return self.has(key) + + def __getitem__(self, key): + return self.get(key) + class CacheDescriptor(object): """ A method decorator that applies a memoizing cache around the function.