Improved caching and utils structure
This commit is contained in:
10
modules/utils/cache_utils.py
Normal file
10
modules/utils/cache_utils.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from typing import Any, Dict, Optional
|
||||
|
||||
from bson import ObjectId
|
||||
from libbot.cache.classes import Cache
|
||||
|
||||
|
||||
def restore_from_cache(
|
||||
cache_prefix: str, cache_key: str | int | ObjectId, cache: Optional[Cache] = None
|
||||
) -> Dict[str, Any] | None:
|
||||
return None if cache is None else cache.get_json(f"{cache_prefix}_{cache_key}")
|
Reference in New Issue
Block a user