protocols
triplum.cache.protocols ¶
Semantic value, storage and serialization boundaries for computation caching.
Fingerprintable ¶
Bases: Protocol
A semantic SHA-256 hex identity that distinguishes the declared value kind.
Select identity-bearing fields explicitly. Bookkeeping timestamps, cache resources and execution policies do not belong in this digest.
fingerprint
abstractmethod
¶
fingerprint() -> str
Source code in src/triplum/cache/protocols.py
18 19 | |
ComputationMetadata
dataclass
¶
ComputationMetadata(
name: str,
source_path: str | None = None,
source_line: int | None = None,
)
Descriptive provenance, excluded from cache identity; location may be unavailable.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
|
source_path |
str | None
|
|
source_line |
int | None
|
|
from_callable
classmethod
¶
from_callable(compute: object) -> ComputationMetadata
Describe a callable without reading source files or invoking user code.
Source code in src/triplum/cache/protocols.py
30 31 32 33 34 35 36 37 38 39 40 | |
CacheKey
dataclass
¶
CacheKey(
process: bytes,
input: bytes,
metadata: ComputationMetadata | None = None,
)
Full computation namespace and input data identity.
Attributes:
| Name | Type | Description |
|---|---|---|
process |
bytes
|
|
input |
bytes
|
|
metadata |
ComputationMetadata | None
|
|
metadata
class-attribute
instance-attribute
¶
metadata: ComputationMetadata | None = field(
default=None, compare=False, hash=False
)
CachePolicy
dataclass
¶
CachePolicy(on_full: Literal['skip', 'block'] = 'skip')
Codec ¶
Bases: Protocol
Serialize a value without changing its semantic content or fingerprint.
encode
abstractmethod
¶
encode(value: T) -> bytes
Source code in src/triplum/cache/protocols.py
70 71 | |
decode
abstractmethod
¶
decode(payload: bytes) -> T
Source code in src/triplum/cache/protocols.py
73 74 | |
CacheBackend ¶
Bases: Protocol
Storage supporting concurrent reads and one writer per Cache owner.
A completed put_many makes all its values visible to subsequent reads. Individual values are atomic; an error may leave a partial batch. close follows all calls.
get
abstractmethod
¶
get(key: CacheKey) -> bytes | None
Source code in src/triplum/cache/protocols.py
84 85 | |
put_many
abstractmethod
¶
put_many(entries: Sequence[tuple[CacheKey, bytes]]) -> None
Source code in src/triplum/cache/protocols.py
87 88 | |
close
abstractmethod
¶
close() -> None
Source code in src/triplum/cache/protocols.py
90 91 | |