<!-- Sema documentation — std.cache
     Sema is a new AI-native, neurosymbolic programming language most models
     have not been trained on. Full corpus: https://sema.49.12.246.95.sslip.io/llms-full.txt
     Install language support: https://sema.49.12.246.95.sslip.io/install-skill/ -->

# std.cache

> Reflected API reference for the Sema standard-library module std.cache.

> Generated by `sema doc` from `stdlib/sema/cache.sema`. Import with `from std.cache import …`. For a narrative introduction see [std.cache](/stdlib/cache/).

# `cache`

std.cache — memoization (design ③).

`memoize` is a decorator: apply `@memoize` to any function to cache its result by
(callee, arguments) for the current run, over the `memory` store. Users can write
variants (TTL, namespacing) as ordinary decorators. `memoize_disk` persists across
runs under `.sema/cache/` (see below).

# `memoize`

```sema
def memoize(fn, args) -> any !{memory.read, memory.write}
```

**Parameters**

| name | type |
|---|---|
| `fn` | `any` |
| `args` | `any` |

**Returns** `any`

**Effects** `!{memory.read, memory.write}`

# `memoize_disk`

```sema
def memoize_disk(fn, args) -> any !{fs.read, fs.write}
```

**Parameters**

| name | type |
|---|---|
| `fn` | `any` |
| `args` | `any` |

**Returns** `any`

**Effects** `!{fs.read, fs.write}`
