perf: replace string concatenation with f-string for cache key generation in get_user_data

This commit is contained in:
retoor 2025-01-24 15:02:33 +00:00
parent 427e0c1b16
commit ba0c7272d8

View File

@ -27,7 +27,7 @@
import time
from functools import wraps
import json
def time_cache(timeout: int = 600):
def decorator(func):
@ -35,7 +35,7 @@ def time_cache(timeout: int = 600):
@wraps(func)
def wrapper(*args, **kwargs):
key = (args, frozenset(kwargs.items()))
key = (json.dumps(args,default=str), json.dumps(frozenset(kwargs.items()),default=str))
current_time = time.time()
if key in cache:
@ -58,7 +58,7 @@ def time_cache_async(timeout: int = 600):
@wraps(func)
async def wrapper(*args, **kwargs):
key = (args, frozenset(kwargs.items()))
key = (json.dumps(args,default=str), json.dumps(frozenset(kwargs.items()),default=str))
current_time = time.time()
if key in cache: