Skip to main content

Filesystem Adapter

The default adapter. Stores memory as versioned JSON files on the local filesystem. No external dependencies required.

Installation

Included with the main amfs package:

Configuration

YAML

Programmatic

Environment Variable


On-Disk Layout

Entries are stored as versioned JSON files organized by namespace, entity, and key:

JSON File Contents

Each file contains a complete MemoryEntry:

Write Safety

The filesystem adapter uses two mechanisms for safe concurrent writes:
  1. Atomic rename — Writes go to a temporary .tmp file, then os.rename() atomically moves it into place. This is safe on POSIX systems even during crashes.
  2. Advisory file lockingflock() on a per-key lock file prevents concurrent writes from interleaving.

Watch

The filesystem adapter watches entity directories for changes and calls your callback when new versions appear.

When to Use

  • Local development
  • Single-machine setups
  • Quick prototyping
  • CI/CD pipelines (ephemeral memory)
For team sharing or multi-machine setups, use the Postgres adapter.