From 5b142788d22fc5c225b4897a914ddf96cfd6a1f0 Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 22 Jan 2016 11:49:59 +0000 Subject: [PATCH] Add __contains__ --- synapse/util/caches/treecache.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/synapse/util/caches/treecache.py b/synapse/util/caches/treecache.py index 2d014e1f9..3b5886091 100644 --- a/synapse/util/caches/treecache.py +++ b/synapse/util/caches/treecache.py @@ -13,6 +13,9 @@ class TreeCache(object): def __setitem__(self, key, value): return self.set(key, value) + def __contains__(self, key): + return self.get(key, SENTINEL) is not SENTINEL + def set(self, key, value): node = self.root for k in key[:-1]: