diff options
author | Jeroen <vo.jeroen@gmail.com> | 2018-07-14 20:24:46 +0200 |
---|---|---|
committer | Jeroen <vo.jeroen@gmail.com> | 2018-07-14 20:24:46 +0200 |
commit | 505530f36abba53234c2fa29262a0de87face4fb (patch) | |
tree | 313bbefb0f7b9693f1189a86410fe3dcdb9207f7 /synapse/util/caches/stream_change_cache.py | |
parent | Merge branch 'develop' into send_sni_for_federation_requests (diff) | |
parent | Fix develop because I broke it :( (#3535) (diff) | |
download | synapse-505530f36abba53234c2fa29262a0de87face4fb.tar.xz |
Merge remote-tracking branch 'upstream/develop' into send_sni_for_federation_requests
# Conflicts: # synapse/crypto/context_factory.py
Diffstat (limited to 'synapse/util/caches/stream_change_cache.py')
-rw-r--r-- | synapse/util/caches/stream_change_cache.py | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/synapse/util/caches/stream_change_cache.py b/synapse/util/caches/stream_change_cache.py index 0fb8620001..a1f8ff8f10 100644 --- a/synapse/util/caches/stream_change_cache.py +++ b/synapse/util/caches/stream_change_cache.py @@ -13,12 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -from synapse.util import caches - +import logging from sortedcontainers import SortedDict -import logging +from synapse.util import caches logger = logging.getLogger(__name__) @@ -75,14 +74,18 @@ class StreamChangeCache(object): assert type(stream_pos) is int if stream_pos >= self._earliest_known_stream_pos: - not_known_entities = set(entities) - set(self._entity_to_key) - - result = ( - {self._cache[k] for k in self._cache.islice( - start=self._cache.bisect_right(stream_pos))} - .intersection(entities) - .union(not_known_entities) - ) + changed_entities = { + self._cache[k] for k in self._cache.islice( + start=self._cache.bisect_right(stream_pos), + ) + } + + # we need to include entities which we don't know about, as well as + # those which are known to have changed since the stream pos. + result = { + e for e in entities + if e in changed_entities or e not in self._entity_to_key + } self.metrics.inc_hits() else: |