mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-03 15:54:49 -04:00
Remove keylen
from LruCache
. (#9993)
`keylen` seems to be a thing that is frequently incorrectly set, and we don't really need it. The only time it was used was to figure out if we had removed a subtree in `del_multi`, which we can do better by changing `TreeCache.pop` to return a different type (`TreeCacheNode`). Commits should be independently reviewable.
This commit is contained in:
parent
316f89e87f
commit
c0df6bae06
11 changed files with 80 additions and 55 deletions
|
@ -13,7 +13,7 @@
|
|||
# limitations under the License.
|
||||
|
||||
|
||||
from synapse.util.caches.treecache import TreeCache
|
||||
from synapse.util.caches.treecache import TreeCache, iterate_tree_cache_entry
|
||||
|
||||
from .. import unittest
|
||||
|
||||
|
@ -64,12 +64,14 @@ class TreeCacheTestCase(unittest.TestCase):
|
|||
cache[("a", "b")] = "AB"
|
||||
cache[("b", "a")] = "BA"
|
||||
self.assertEquals(cache.get(("a", "a")), "AA")
|
||||
cache.pop(("a",))
|
||||
popped = cache.pop(("a",))
|
||||
self.assertEquals(cache.get(("a", "a")), None)
|
||||
self.assertEquals(cache.get(("a", "b")), None)
|
||||
self.assertEquals(cache.get(("b", "a")), "BA")
|
||||
self.assertEquals(len(cache), 1)
|
||||
|
||||
self.assertEquals({"AA", "AB"}, set(iterate_tree_cache_entry(popped)))
|
||||
|
||||
def test_clear(self):
|
||||
cache = TreeCache()
|
||||
cache[("a",)] = "A"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue