mixle.experimental.typed_runtime.cache module¶
Versioned local artifact cache driven by update-graph invalidation.
- class CachedArtifact(node_id, artifact, generation, value)[source]
Bases:
objectOne cached value tied to the producing node’s generation.
- class InvalidationReceipt(source_nodes, written_artifact, invalidated_nodes, removed_entries, generations)[source]
Bases:
objectExact cache entries and node generations invalidated by a write.
- Parameters:
- class VersionedArtifactCache(graph)[source]
Bases:
objectThread-safe local cache with graph-derived transitive invalidation.
A node generation advances even when no entry currently exists. A late worker can therefore compare its captured generation to the current one and detect that its result was computed before an intervening update.
- Parameters:
graph (UpdateGraph)
- generation(node_id)[source]
Return the current generation for a node.
- put(node_id, artifact, value)[source]
Store a value at the node’s current generation.
- get(node_id, artifact)[source]
Return a current value or raise
KeyErrorfor absent/stale data.
- contains(node_id, artifact)[source]
Whether a current cache entry exists.
- invalidate(source_node, written_artifact=ArtifactKind.PARAMETERS)[source]
Invalidate one source and every transitively dependent node.
- Parameters:
source_node (str)
written_artifact (ArtifactKind)
- Return type:
InvalidationReceipt
- invalidate_many(source_nodes, written_artifact=ArtifactKind.PARAMETERS)[source]
Atomically invalidate the union of several dependency closures.
- Parameters:
source_nodes (Collection[str])
written_artifact (ArtifactKind)
- Return type:
InvalidationReceipt
- clear()[source]
Invalidate all nodes and remove all entries.
- Return type:
None