diff options
author | Erik Johnston <erik@matrix.org> | 2021-04-02 11:28:51 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2021-04-02 11:28:51 +0100 |
commit | e2b2decd1177654867f46cdb11529fbb1f5a4f30 (patch) | |
tree | bc0054234567fc209ba83de3c27c3f285e7c9ed1 /tests/util/test_lrucache.py | |
parent | fix (diff) | |
download | synapse-e2b2decd1177654867f46cdb11529fbb1f5a4f30.tar.xz |
Diffstat (limited to 'tests/util/test_lrucache.py')
-rw-r--r-- | tests/util/test_lrucache.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/util/test_lrucache.py b/tests/util/test_lrucache.py index a739a6aaaf..dd8c46ee49 100644 --- a/tests/util/test_lrucache.py +++ b/tests/util/test_lrucache.py @@ -30,6 +30,23 @@ class LruCacheTestCase(unittest.HomeserverTestCase): self.assertEquals(cache.get("key"), "value") self.assertEquals(cache["key"], "value") + def test_time_evict(self): + self.reactor.advance(100 * 60) + + cache = LruCache(100, reactor=self.reactor) + cache["key"] = "value" + cache["key2"] = "value2" + + cache._on_resize() + self.assertEquals(cache.get("key"), "value") + + self.reactor.advance(20 * 60) + + print(self.reactor.seconds()) + + cache._on_resize() + self.assertEquals(cache.get("key"), None) + def test_eviction(self): cache = LruCache(2) cache[1] = 1 |