perf: replace string concatenation with f-string for cache key generation in get_user_data
This commit is contained in:
parent
427e0c1b16
commit
ba0c7272d8
@ -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:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user