mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Fix faulty cache
This commit is contained in:
parent
e1b555781c
commit
6e6098b03a
@ -5,7 +5,7 @@ from typing import Any, Optional, Tuple
|
||||
|
||||
type Cache = dict[Any, Tuple[Optional[asyncio.Event], Optional[datetime], Any]]
|
||||
|
||||
def cache(ttl: timedelta, cache: Cache={}, typed=False):
|
||||
def cache(ttl: timedelta, cache: Optional[Cache] = None, typed=False):
|
||||
"""
|
||||
A cache decorator for async methods. If the same method is called twice with
|
||||
the same args, the underlying method will only be called once and the first
|
||||
@ -17,6 +17,9 @@ def cache(ttl: timedelta, cache: Cache={}, typed=False):
|
||||
|
||||
"""
|
||||
|
||||
if cache is None:
|
||||
cache = {}
|
||||
|
||||
def wrap(f):
|
||||
@wraps(f)
|
||||
async def wrapper(*args, **kwargs):
|
||||
|
Loading…
x
Reference in New Issue
Block a user