mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-10-01 08:25:44 -04:00
Merge pull request #3530 from matrix-org/erikj/stream_cache
Don't return unknown entities in get_entities_changed
This commit is contained in:
commit
3fe0938b76
0
changelog.d/3530.misc
Normal file
0
changelog.d/3530.misc
Normal file
@ -74,19 +74,12 @@ class StreamChangeCache(object):
|
|||||||
assert type(stream_pos) is int
|
assert type(stream_pos) is int
|
||||||
|
|
||||||
if stream_pos >= self._earliest_known_stream_pos:
|
if stream_pos >= self._earliest_known_stream_pos:
|
||||||
changed_entities = {
|
result = {
|
||||||
self._cache[k] for k in self._cache.islice(
|
self._cache[k] for k in self._cache.islice(
|
||||||
start=self._cache.bisect_right(stream_pos),
|
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()
|
self.metrics.inc_hits()
|
||||||
else:
|
else:
|
||||||
result = set(entities)
|
result = set(entities)
|
||||||
|
@ -141,8 +141,8 @@ class StreamChangeCacheTests(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Query all the entries mid-way through the stream, but include one
|
# Query all the entries mid-way through the stream, but include one
|
||||||
# that doesn't exist in it. We should get back the one that doesn't
|
# that doesn't exist in it. We shouldn't get back the one that doesn't
|
||||||
# exist, too.
|
# exist.
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
cache.get_entities_changed(
|
cache.get_entities_changed(
|
||||||
[
|
[
|
||||||
@ -153,7 +153,7 @@ class StreamChangeCacheTests(unittest.TestCase):
|
|||||||
],
|
],
|
||||||
stream_pos=2,
|
stream_pos=2,
|
||||||
),
|
),
|
||||||
set(["bar@baz.net", "user@elsewhere.org", "not@here.website"]),
|
set(["bar@baz.net", "user@elsewhere.org"]),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Query all the entries, but before the first known point. We will get
|
# Query all the entries, but before the first known point. We will get
|
||||||
|
Loading…
Reference in New Issue
Block a user