Skip to content

Commit

Permalink
Updated caching
Browse files Browse the repository at this point in the history
  • Loading branch information
berrysauce committed Sep 5, 2023
1 parent 517a227 commit 136a469
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ def get_scan(url: str, includeCategories: Optional[bool] = False):
try:
cache_data = cache_db.get(key=url)
if cache_data != None:
# move "other" to the end of the dict
cache_data["other"] = cache_data.pop("other")
return cache_data
except Exception:
# Deta hasn't defined a specific exception for this error
Expand Down Expand Up @@ -122,7 +120,10 @@ def get_scan(url: str, includeCategories: Optional[bool] = False):
# add data to cache
# expiry: 15 minutes (900 seconds)
try:
cache_db.put(key=url, data=return_data, expire_in=900)
# move "other" to the end of the dict
new_cache_data = return_data
new_cache_data["other"] = new_cache_data.pop("other")
cache_db.put(key=url, data=new_cache_data, expire_in=900)
except Exception:
# Deta hasn't defined a specific exception for this error
# just ignore it
Expand Down

0 comments on commit 136a469

Please sign in to comment.