Infrastructure · Data Structures
Cache
Keyed storage for reusing previously obtained values
Definition
Mechanism
A temporary keyed storage layer for keeping frequently accessed Datum or State alongside the inputs that produced them, so repeat lookups bypass re-computation. Read-through, write-behind, and invalidation discipline are descendant concerns; the foundation is the keyed lookup that returns a stored value if present.
Preconditions
- Key is hashable
- Value is serializable
Postconditions
- On a cache hit, the stored value for the requested key is returned without requiring recomputation.
Invariants
- Consistency: Cache(Key) == Source(Key) if valid.
- Freshness: Expired items must not be returned.
Risks
Failure modes
Staleness
Serving outdated data after the source has changed.
Thrashing
Frequent evictions due to insufficient size.
Relationships
Builds on
Used by
References
Mind
Rapid, low-cost decision making via pattern recognition
Safe retries via unique keys
Mind
Learned routing memory: problem_class → route → outcome_quality
Reference
Data schema
{
"type": "object",
"description": "Keyed-value storage with lookup semantics.",
"properties": {
"key": {
"type": "string",
"description": "Lookup key. Required: a keyed store with no key is not a cache."
},
"value": {
"description": "Stored value returned on a hit."
},
"hit": {
"type": "boolean",
"description": "Whether the key was found on lookup"
}
},
"required": [
"key",
"value"
]
}