diff options
author | Erik Johnston <erik@matrix.org> | 2016-01-29 16:54:34 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2016-01-29 16:54:34 +0000 |
commit | 226a9a5fa6afac1a5d16599a6bd2744805a37c28 (patch) | |
tree | 06a9bbb7fdc3f05c62115101b915b69d876ab0b8 | |
parent | Merge pull request #540 from matrix-org/erikj/sync (diff) | |
parent | Invalidate _account_data_stream_cache correctly (diff) | |
download | synapse-226a9a5fa6afac1a5d16599a6bd2744805a37c28.tar.xz |
Merge pull request #542 from matrix-org/erikj/cache_fix
Cache fixes
-rw-r--r-- | synapse/storage/account_data.py | 4 | ||||
-rw-r--r-- | synapse/util/caches/stream_change_cache.py | 11 |
2 files changed, 7 insertions, 8 deletions
diff --git a/synapse/storage/account_data.py b/synapse/storage/account_data.py index 625d062eb1..b8387fc500 100644 --- a/synapse/storage/account_data.py +++ b/synapse/storage/account_data.py @@ -157,6 +157,10 @@ class AccountDataStore(SQLBaseStore): "content": content_json, } ) + txn.call_after( + self._account_data_stream_cache.entity_has_changed, + user_id, next_id, + ) self._update_max_stream_id(txn, next_id) with (yield self._account_data_id_gen.get_next(self)) as next_id: diff --git a/synapse/util/caches/stream_change_cache.py b/synapse/util/caches/stream_change_cache.py index 891cb619fa..b37f1c0725 100644 --- a/synapse/util/caches/stream_change_cache.py +++ b/synapse/util/caches/stream_change_cache.py @@ -52,15 +52,10 @@ class StreamChangeCache(object): cache_counter.inc_misses(self.name) return True - if stream_pos == self._earliest_known_stream_pos: - # If the same as the earliest key, assume nothing has changed. - cache_counter.inc_hits(self.name) - return False - latest_entity_change_pos = self._entity_to_key.get(entity, None) if latest_entity_change_pos is None: - cache_counter.inc_misses(self.name) - return True + cache_counter.inc_hits(self.name) + return False if stream_pos < latest_entity_change_pos: cache_counter.inc_misses(self.name) @@ -98,7 +93,7 @@ class StreamChangeCache(object): if stream_pos > self._earliest_known_stream_pos: old_pos = self._entity_to_key.get(entity, None) - if old_pos: + if old_pos is not None: stream_pos = max(stream_pos, old_pos) self._cache.pop(old_pos, None) self._cache[stream_pos] = entity |