mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 11:06:07 -04:00
Add a unit test for the snapshot cache
This commit is contained in:
parent
517fb9a023
commit
7fa71e3267
2 changed files with 62 additions and 2 deletions
|
@ -28,14 +28,14 @@ class SnapshotCache(object):
|
|||
|
||||
def rotate(self, time_now_ms):
|
||||
# Rotate once if the cache duration has passed since the last rotation.
|
||||
if time_now_ms - self.time_last_rotated_ms > self.DURATION_MS:
|
||||
if time_now_ms - self.time_last_rotated_ms >= self.DURATION_MS:
|
||||
self.prev_result_cache = self.next_result_cache
|
||||
self.next_result_cache = {}
|
||||
self.time_last_rotated_ms += self.DURATION_MS
|
||||
|
||||
# Rotate again if the cache duration has passed twice since the last
|
||||
# rotation.
|
||||
if time_now_ms - self.time_last_rotated_ms > self.DURATION_MS:
|
||||
if time_now_ms - self.time_last_rotated_ms >= self.DURATION_MS:
|
||||
self.prev_result_cache = self.next_result_cache
|
||||
self.next_result_cache = {}
|
||||
self.time_last_rotated_ms = time_now_ms
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue