Check that cache entry exists before deleting

merge-requests/20/merge
Bob Mottram 2021-03-25 22:02:31 +00:00
parent 8b8af40c64
commit abf822abac
1 changed files with 4 additions and 2 deletions

View File

@ -1546,8 +1546,10 @@ def updateRecentPostsCache(recentPostsCache: {}, maxRecentPosts: int,
while len(recentPostsCache['html'].items()) > maxRecentPosts:
postId = recentPostsCache['index'][0]
recentPostsCache['index'].pop(0)
del recentPostsCache['json'][postId]
del recentPostsCache['html'][postId]
if recentPostsCache['json'].get(postId):
del recentPostsCache['json'][postId]
if recentPostsCache['html'].get(postId):
del recentPostsCache['html'][postId]
else:
recentPostsCache['index'] = [postId]
recentPostsCache['json'] = {}