assets_guardian.core.cache.cacheο
Classes
|
Temporary cache and JSONL persistence manager. |
|
Iterable that reloads data from the disk at each iteration. |
- class assets_guardian.core.cache.cache.CacheManager(config: CacheConfig | None = None)[source]ο
Bases:
objectTemporary cache and JSONL persistence manager.
Allows offloading RAM by writing collected data to disk and managing checkpoints for crash recovery.
- cleanup(command: str, env: AppEnv) None[source]ο
Deletes all temporary files associated with a given command.
- Parameters:
command β Name of the command concerned.
- get_file_path(command: str, source: str, instance_id: str, data_type: str) Path[source]ο
Generates a unique, command-isolated file path.
- Parameters:
command β Name of the command (e.g., βsyncβ, βauditβ).
source β Source name (e.g., βgitlabβ).
instance_id β Instance ID (e.g., βprodβ).
data_type β Data type (e.g., βidentitiesβ, βassetsβ, βaccessesβ).
- has_checkpoint(path: Path) bool[source]ο
Checks if a checkpoint file exists.
- Parameters:
path β Path of the checkpoint file.
- load(file_path: Path, item_type: type[ModelType]) Iterator[source]ο
Loads a JSONL file as an iterator of typed objects by reading in blocks.
Reads the file in batches of N lines to optimize performance without saturating RAM.
- Parameters:
file_path β Path of the JSONL file to read.
item_type β The class (dataclass) to deserialize into.
- Yields:
ModelType β The deserialized objects one by one.
- load_iterable(file_path: Path, item_type: type[ModelType]) LazyCacheIterable[source]ο
Returns an iterable object that reloads from disk without loading into RAM.
- Parameters:
file_path β Path of the JSONL file.
item_type β The class to deserialize into.
- Returns:
A reusable iterable tied to the file.
- Return type:
- class assets_guardian.core.cache.cache.LazyCacheIterable(service: CacheManager, file_path: Path, item_type: type[ModelType])[source]ο
Bases:
GenericIterable that reloads data from the disk at each iteration.