Two-Level Incremental Build Cache Manager.

L1 Parsing Cache: skips processing unchanged XML source files by validating file metadata (size/mtime) and content checksum.

L2 Rendering Cache: skips writing identical generated markdown/HTML targets to disk to avoid triggering SSG livereload cascades.

Instance Variables

  • ude.storage.BuildCacheManager.product_dir
  • ude.storage.BuildCacheManager.cache_path
  • BuildCache ude.storage.BuildCacheManager._cache

Methods

init

__init__(self, product_dir: Union)

Binds this cache manager to product_dir, loading any existing cache database.

ParameterTypeDescription
product_dirUnionOutput directory this cache instance is bound to;

save

save(self)

Saves and compresses the current cache database state to disk.

get_l1_entry

get_l1_entry(self, xml_path: Union) -> Optional[ProjectCatalog]

Returns cached ProjectCatalog if XML source file is unchanged, else None.

Returns:

The cached ProjectCatalog if its L1 entry’s mtime/size/sha256

ParameterTypeDescription
xml_pathUnionPath to the XML source file to check.

set_l1_entry

set_l1_entry(self, xml_path: Union, catalog: ProjectCatalog)

Saves ProjectCatalog metadata into the Level 1 parsing cache database.

ParameterTypeDescription
xml_pathUnionPath to the XML source file that was parsed.
catalogProjectCatalogThe resulting parsed ProjectCatalog to cache.

check_l2_hit

check_l2_hit(self, target_path: Union, entity_signature: str, template_content: str) -> bool

Returns True if Level 2 cache hits and target output file physically exists on disk.

Returns:

True if the target exists on disk and its cached signature matches.

ParameterTypeDescription
target_pathUnionPath to the output file that would be written.
entity_signaturestrStable hash identifying the source state behind the content.
template_contentstrThe template content used to render the target, for hashing.

set_l2_entry

set_l2_entry(self, target_path: Union, entity_signature: str, template_content: str)

Records rendering target signatures inside Level 2 rendering cache database.

ParameterTypeDescription
target_pathUnionPath to the output file that was written.
entity_signaturestrStable hash identifying the source state behind the content.
template_contentstrThe template content used to render the target, for hashing.

write_if_changed

write_if_changed(self, target_path: Union, content: str, entity_signature: str, template_content: str) -> bool

Writes content to disk only if Level 2 rendering signatures differ, preventing redundant I/O.

Returns:

True if write was executed, False if skipped.

ParameterTypeDescription
target_pathUnionPath to the output file to write.
contentstrThe fully rendered content to persist.
entity_signaturestrStable hash identifying the source state behind the content.
template_contentstrThe template content used to render the target, for hashing.

_load_cache

_load_cache(self) -> BuildCache

Loads and decompresses the persistent cache database from disk.

Returns:

The loaded BuildCache, or an empty one if the cache file is