Skip to content
shelf logo

shelf

Fast in-memory access with automatic disk persistence for the BEAM.

ETS Speed + DETS Persistence

Microsecond reads from ETS with durable storage on disk via DETS. The classic Erlang persistence pattern, wrapped in a type-safe Gleam API.

Runtime Type Safety

Decoder-gated loading validates every entry from disk against your Gleam types. Catch corrupted or mistyped data at the storage boundary.

Write Modes

Choose WriteBack for high-throughput batched persistence, or WriteThrough for immediate durability on every write.

Table Types

Set, bag, and duplicate bag tables — all with persistent backing. Pick the right data model for your use case.

Safe Resource Management

The with_table callback ensures tables are always properly closed, even when the body panics or returns an error.

Atomic Counters

Lock-free integer increments via update_counter — increment hit counts or sequence numbers without serialising through an actor.

Cross-process reads

ETS tables are created protected, so any process can read them concurrently while a single owner process handles writes — a natural fit for actor-fronted, read-heavy services.