Update to v1.5.1

Signed-off-by: Kai A. Hiller <V02460@gmail.com>
This commit is contained in:
Kai A. Hiller 2019-11-08 13:00:23 +01:00
parent c495426260
commit dd77290a2d
3 changed files with 24 additions and 11 deletions

View file

@ -3,7 +3,7 @@
%{?python_enable_dependency_generator} %{?python_enable_dependency_generator}
Name: matrix-%{srcname} Name: matrix-%{srcname}
Version: 1.5.0 Version: 1.5.1
Release: 1%{?dist} Release: 1%{?dist}
Summary: A Matrix reference homeserver written in Python using Twisted Summary: A Matrix reference homeserver written in Python using Twisted
License: ASL 2.0 License: ASL 2.0

View file

@ -1,5 +1,5 @@
diff --git a/synapse/util/caches/descriptors.py b/synapse/util/caches/descriptors.py diff --git a/synapse/util/caches/descriptors.py b/synapse/util/caches/descriptors.py
index 5ac2530a6..bddadd629 100644 index 5ac2530a6..d803d62b8 100644
--- a/synapse/util/caches/descriptors.py --- a/synapse/util/caches/descriptors.py
+++ b/synapse/util/caches/descriptors.py +++ b/synapse/util/caches/descriptors.py
@@ -17,8 +17,8 @@ import functools @@ -17,8 +17,8 @@ import functools
@ -7,12 +7,22 @@ index 5ac2530a6..bddadd629 100644
import logging import logging
import threading import threading
-from collections import namedtuple -from collections import namedtuple
from typing import Any, cast -from typing import Any, cast
+from typing import Any, Tuple, Union, cast
+from weakref import WeakValueDictionary +from weakref import WeakValueDictionary
from six import itervalues from six import itervalues
@@ -430,7 +430,7 @@ class CacheDescriptor(_CacheDescriptorBase): @@ -38,6 +38,8 @@ from . import register_cache
logger = logging.getLogger(__name__)
+CacheKey = Union[Tuple, Any]
+
class _CachedFunction(Protocol):
invalidate = None # type: Any
@@ -430,7 +432,7 @@ class CacheDescriptor(_CacheDescriptorBase):
# Add our own `cache_context` to argument list if the wrapped function # Add our own `cache_context` to argument list if the wrapped function
# has asked for one # has asked for one
if self.add_cache_context: if self.add_cache_context:
@ -21,7 +31,7 @@ index 5ac2530a6..bddadd629 100644
try: try:
cached_result_d = cache.get(cache_key, callback=invalidate_callback) cached_result_d = cache.get(cache_key, callback=invalidate_callback)
@@ -625,14 +625,36 @@ class CacheListDescriptor(_CacheDescriptorBase): @@ -625,14 +627,38 @@ class CacheListDescriptor(_CacheDescriptorBase):
return wrapped return wrapped
@ -31,6 +41,8 @@ index 5ac2530a6..bddadd629 100644
- # their caches and keys match). This is important in particular to - # their caches and keys match). This is important in particular to
- # dedupe when we add callbacks to lru cache nodes, otherwise the number - # dedupe when we add callbacks to lru cache nodes, otherwise the number
- # of callbacks would grow. - # of callbacks would grow.
- def invalidate(self):
- self.cache.invalidate(self.key)
+class _CacheContext: +class _CacheContext:
+ """Holds cache information from the cached function higher in the calling order. + """Holds cache information from the cached function higher in the calling order.
+ +
@ -38,19 +50,20 @@ index 5ac2530a6..bddadd629 100644
+ on a lower level. + on a lower level.
+ """ + """
+ +
+ _cache_context_objects = WeakValueDictionary() + _cache_context_objects = (
+ WeakValueDictionary()
+ ) # type: WeakValueDictionary[Tuple[Cache, CacheKey], _CacheContext]
+ +
+ def __init__(self, cache, cache_key): + def __init__(self, cache, cache_key): # type: (Cache, CacheKey) -> None
+ self._cache = cache + self._cache = cache
+ self._cache_key = cache_key + self._cache_key = cache_key
+ +
def invalidate(self): + def invalidate(self): # type: () -> None
- self.cache.invalidate(self.key)
+ """Invalidates the cache entry referred to by the context.""" + """Invalidates the cache entry referred to by the context."""
+ self._cache.invalidate(self._cache_key) + self._cache.invalidate(self._cache_key)
+ +
+ @classmethod + @classmethod
+ def get_instance(cls, cache, cache_key): + def get_instance(cls, cache, cache_key): # type: (Cache, CacheKey) -> _CacheContext
+ """Returns an instance constructed with the given arguments. + """Returns an instance constructed with the given arguments.
+ +
+ A new instance is only created if none already exists. + A new instance is only created if none already exists.

View file

@ -1 +1 @@
SHA512 (synapse-1.5.0.tar.gz) = dd870182dcc33f50cc558426d47f9eb06e370a445297bc28f70cb201ed01293106264f6511e51d3d90c27ba08dd600e8709e89bdace3c7023c36591349aebc94 SHA512 (synapse-1.5.1.tar.gz) = 395b568e1643dc6d4e9fd2ea667efb54685f9058f5049b0e12a90de867fca71104ad1310639200d25f0accd563456e0110a931a8e0030d63b8b3154e366436ca