Dispatch
1.x
Docs/Dispatch/Memory Store
Open

Reading1 min
Updated31 Jul 2026
Sourcev1/stores/memory.mdx

The memory store keeps all data in Go maps protected by a sync.RWMutex. It requires zero configuration and is the default store for unit tests.

When to use01

  • Unit tests -- Fast, deterministic, no external dependencies.

  • Local development -- Get started without setting up a database.

  • Prototyping -- Validate business logic before choosing a persistence layer.

Data is lost when the process exits.

Usage02

import "github.com/xraph/relay/store/memory"

s := memory.New()

r, err := relay.New(relay.WithStore(s))

Internals03

AspectDetail
Concurrencysync.RWMutex -- reads run concurrently, writes are exclusive
IndexingMap keys by ID string; linear scan for list/filter
MigrateNo-op
PingNo-op (always succeeds)
CloseNo-op

Limitations04

  • No persistence -- all data lost on restart.

  • List operations are O(n) scans.

  • Single process only.

  • No multi-operation transactions.