Skip to content

Commit

Permalink
fix storing cache correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
spookybear0 committed May 14, 2024
1 parent f01fad6 commit 26bd285
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions helpers/cachehelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,19 @@ async def wrapper(*args, **kwargs):
request: Request = args[0]
request_args = request.args

request = None
request_args = None
request_json = None
if len(args) > 0 and isinstance(args[0], Request):
request: Request = args[0]
request_args = request.args
request_json = request.json

key = f"{f.__name__}_{args}_{kwargs}"
if request_args:
key += f"_{request_args}"
if request_json:
key += f"_{request_json}"
result = None

if key in function_cache:
Expand Down Expand Up @@ -120,8 +130,21 @@ async def wrapper(*args, **kwargs) -> str:
args = await f(*args, **kwargs)
from utils import render_template
return await render_template(args[0], args[1], *args[2], **args[3])

request = None
request_args = None
request_json = None
if len(args) > 0 and isinstance(args[0], Request):
request: Request = args[0]
request_args = request.args
request_json = request.json

key = f"{f.__name__}_{args}_{kwargs}"
if request_args:
key += f"_{request_args}"
if request_json:
key += f"_{request_json}"

result = None

if key in function_cache:
Expand Down

0 comments on commit 26bd285

Please sign in to comment.