mixle.experimental.typed_runtime.cache module

Versioned local artifact cache driven by update-graph invalidation.

class CachedArtifact(node_id, artifact, generation, value)[source]

Bases: object

One cached value tied to the producing node’s generation.

Parameters:
  • node_id (str)

  • artifact (ArtifactKind)

  • generation (int)

  • value (Any)

class InvalidationReceipt(source_nodes, written_artifact, invalidated_nodes, removed_entries, generations)[source]

Bases: object

Exact cache entries and node generations invalidated by a write.

Parameters:
as_dict()[source]

Return a JSON-compatible receipt without cached values.

Return type:

dict[str, Any]

class VersionedArtifactCache(graph)[source]

Bases: object

Thread-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.

Parameters:

node_id (str)

Return type:

int

put(node_id, artifact, value)[source]

Store a value at the node’s current generation.

Parameters:
  • node_id (str)

  • artifact (ArtifactKind)

  • value (Any)

Return type:

CachedArtifact

get(node_id, artifact)[source]

Return a current value or raise KeyError for absent/stale data.

Parameters:
  • node_id (str)

  • artifact (ArtifactKind)

Return type:

Any

contains(node_id, artifact)[source]

Whether a current cache entry exists.

Parameters:
  • node_id (str)

  • artifact (ArtifactKind)

Return type:

bool

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:
Return type:

InvalidationReceipt

clear()[source]

Invalidate all nodes and remove all entries.

Return type:

None

as_dict()[source]

Return cache metadata without serializing runtime values.

Return type:

dict[str, Any]