From 09b86f295159145e355c8e80bc3f9fc3b1ab056f Mon Sep 17 00:00:00 2001 From: lub Date: Mon, 4 May 2020 20:15:30 +0200 Subject: [PATCH] add some buffer to our cache --- scrape.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scrape.py b/scrape.py index 50c91a7..0055df3 100644 --- a/scrape.py +++ b/scrape.py @@ -172,7 +172,9 @@ async def main(): # add url to cache cache += [post['url']] - while len(cache) > len(blog): + # check for double the post count, to have some buffer for manually purging URLs + # otherwise the cache could reshuffle when you remove too many URLs at once + while len(cache) > len(blog)*2: cache.remove(cache[0]) set_state = await matrix[next(iter(matrix))].room_put_state(room_id=admin_room, event_type=event_type_prefix+'cache',