class LocalCache

source code

Local file-based cache implementation.

setters


set_cache_name

source code

def set_cache_name(cls, name: str) -> None:
Set the cache filename and reset the in-memory cache.

methods


get_cache_filepath

source code

def get_cache_filepath(cls, name: str = None) -> str:
Get the full filepath for the cache file.

get_cache_name

source code

def get_cache_name(cls) -> str:
Get the current cache filename.

has_key

source code

def has_key(cls, key: str) -> bool:
Check if a key exists in the cache.

initialize_cache

source code

def initialize_cache(cls, name: str = None) -> None:
Initialize or load the cache from disk.

is_enabled

source code

def is_enabled(cls) -> bool:
Check if the cache is enabled.

list_keys

source code

def list_keys(cls) -> List[str]:

remove_entry

source code

def remove_entry(cls, key: str) -> None:
Remove an entry and its res_types from the cache.

retrieve_entry

source code

def retrieve_entry(cls, key: str) -> tuple[Optional[Any], Optional[Dict[str, Any]]]:
Retrieve a value from the cache. Returns: Tuple of (value, type_registry) or (None, None) if not found

serialize_object

source code

def serialize_object(
        obj: Any,
        cached_types: Dict[str, str] = None,
        idx: List[Union[str, int]] = None,
        indent: int = None,
    ) -> Any:
Serialize an object to a JSON-serializable format. Arguments:
  • obj - Object to serialize
  • type_registry - Dictionary to track object types for reconstruction
  • path - Current path in the object structure
  • indent - JSON indentation level
Returns: Serialized object or JSON string if at root level

store_entry

source code

def store_entry(
        cls,
        *,
        key: str,
        value: Any,
        res_types: Optional[Dict[str, Any]] = None,
    ) -> None:
Store a key-value pair in the cache.

write

source code

def write(cls, filename: str = None) -> None:
Write the cache to disk.