diff options
author | David Baker <dbkr@users.noreply.github.com> | 2016-01-22 14:47:48 +0000 |
---|---|---|
committer | David Baker <dbkr@users.noreply.github.com> | 2016-01-22 14:47:48 +0000 |
commit | 7a3fe48ba48d99f02b4bfd556199571f95fc8e1c (patch) | |
tree | 740e160954c47d5362c22661bb141c31cdfbf118 /tests/util/test_lrucache.py | |
parent | Merge pull request #517 from matrix-org/erikj/push_only_room (diff) | |
parent | Don't add the member functiopn if we're not using treecache (diff) | |
download | synapse-7a3fe48ba48d99f02b4bfd556199571f95fc8e1c.tar.xz |
Merge pull request #519 from matrix-org/dbkr/treecache
Make LRU caching tree-based so subtrees of the cache can be invalidated cheaply.
Diffstat (limited to 'tests/util/test_lrucache.py')
-rw-r--r-- | tests/util/test_lrucache.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/util/test_lrucache.py b/tests/util/test_lrucache.py index fbbc5eed15..2cd3d26454 100644 --- a/tests/util/test_lrucache.py +++ b/tests/util/test_lrucache.py @@ -17,6 +17,7 @@ from .. import unittest from synapse.util.caches.lrucache import LruCache +from synapse.util.caches.treecache import TreeCache class LruCacheTestCase(unittest.TestCase): @@ -52,3 +53,22 @@ class LruCacheTestCase(unittest.TestCase): cache["key"] = 1 self.assertEquals(cache.pop("key"), 1) self.assertEquals(cache.pop("key"), None) + + def test_del_multi(self): + cache = LruCache(4, 2, cache_type=TreeCache) + cache[("animal", "cat")] = "mew" + cache[("animal", "dog")] = "woof" + cache[("vehicles", "car")] = "vroom" + cache[("vehicles", "train")] = "chuff" + + self.assertEquals(len(cache), 4) + + self.assertEquals(cache.get(("animal", "cat")), "mew") + self.assertEquals(cache.get(("vehicles", "car")), "vroom") + cache.del_multi(("animal",)) + self.assertEquals(len(cache), 2) + self.assertEquals(cache.get(("animal", "cat")), None) + self.assertEquals(cache.get(("animal", "dog")), None) + self.assertEquals(cache.get(("vehicles", "car")), "vroom") + self.assertEquals(cache.get(("vehicles", "train")), "chuff") + # Man from del_multi say "Yes". |