Improved caching and utils structure

This commit is contained in:
2025-04-22 23:22:01 +02:00
parent ec094f9a98
commit 5230ac9ace
15 changed files with 65 additions and 40 deletions

View 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}")