project_config.cache module

Persistent cache.

class project_config.cache.Cache[source]

Bases: object

Global cache to avoid recomputing expensive intermediate objects.

_expiration_time: float | int | None = 30
static clean() None[source]

Remove the cache directory.

classmethod ensure_dir() None[source]

Ensure the cache directory exists.

classmethod generate_unique_key_from_tree_entry(tree_entry: str) str[source]

Generate a unique key.

classmethod get(tree_entry: str) Any[source]
classmethod set(tree_entry: str, value: Any) None[source]
classmethod set_expiration_time(expiration_time: Optional[Union[float, int]] = None) None[source]

Configure global cache.

Parameters:

expiration_time (float) – Expiration time in seconds for cached objects.

project_config.cache.generate_possible_cache_dirs() Iterator[str][source]

Generate the possible cache directories.

project_config.cache.get_creation_time_from_fpath(fpath: str) int[source]

Get creation time of an entry in the cache given its path.

project_config.cache.read_file(fpath: str) bytes[source]

Read a file from the cache.

project_config.cache.write_file(fpath: str, value: Any) None[source]

Write a file to the cache.