---
slug: "Cache"
name: "Cache"
type: "Data Structures"
layer: "Infrastructure"
ref: "Cache#465f"
sema_id: "sema:Cache#mh:SHA-256:465f391fb70426b0ec99c724ecf5db549d4f2e8124c821530271124aa10e17f3"
tags: ["Infrastructure","Data Structures"]
updated: 2026-11-11
mindscape: "bootstrap"
index_url: https://mindscape.pages.dev/bootstrap/index.json
url: https://mindscape.pages.dev/bootstrap/Cache/
related: ["Datum","State","HeuristicSnap","IdempotentWrite","PathwayMemory"]
---

# Cache

Keyed storage for reusing previously obtained values

Layer: Infrastructure · Category: Data Structures

## Mechanism

A temporary keyed storage layer for keeping frequently accessed [Datum](https://mindscape.pages.dev/bootstrap/Datum.md) or [State](https://mindscape.pages.dev/bootstrap/State.md) 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.

## Invariants

- Consistency: Cache(Key) == Source(Key) if valid.
- Freshness: Expired items must not be returned.

## Preconditions

- Key is hashable
- Value is serializable

## Postconditions

- On a cache hit, the stored value for the requested key is returned without requiring recomputation.

## Failure modes

- Staleness: Serving outdated data after the source has changed.
- Thrashing: Frequent evictions due to insufficient size.

## Data schema

```json
{
  "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"
  ]
}
```

## Builds on

- [Datum](https://mindscape.pages.dev/bootstrap/Datum.md) (Infrastructure; References)
- [State](https://mindscape.pages.dev/bootstrap/State.md) (Infrastructure; References)

## Used by

- [HeuristicSnap](https://mindscape.pages.dev/bootstrap/HeuristicSnap.md) (Mind; References)
- [IdempotentWrite](https://mindscape.pages.dev/bootstrap/IdempotentWrite.md) (Infrastructure; References)
- [PathwayMemory](https://mindscape.pages.dev/bootstrap/PathwayMemory.md) (Mind; References)

## Identity

- Sema ID: `sema:Cache#mh:SHA-256:465f391fb70426b0ec99c724ecf5db549d4f2e8124c821530271124aa10e17f3`
- Ref: `Cache#465f`
- Supersedes:
  - `sema:Cache#mh:SHA-256:1ea9ba40ef01b9f6072ae6bb93d37096c11655bb43a5bebe172d50365dde1073`
  - `sema:Cache#mh:SHA-256:30c9445ad9acaafbda91309d2ac5da1b52aec6d5e7fee8c097fd666cb11cefa5`
  - `sema:Cache#mh:SHA-256:55e2dfe59df3e261e74c0ecdafa7216cf6fea44e60692125499924c7a8104771`

## Links

- [Pattern page](https://mindscape.pages.dev/bootstrap/Cache/)
- [View in the interactive graph](https://mindscape.pages.dev/bootstrap/#Cache)
- [JSON](https://mindscape.pages.dev/bootstrap/Cache.json)
- [Index of all patterns](https://mindscape.pages.dev/bootstrap/index.json)
