Grove.Storage.DETS (Grove v0.1.1)

View Source

Persistent disk storage backend using DETS.

Provides durable storage that survives node restarts. Data is written to disk and automatically persisted.

Features

  • Survives node restarts
  • Auto-save at configurable intervals
  • Same API as ETS backend

Limitations

  • 2GB maximum file size
  • Slower than ETS (disk I/O)
  • No concurrent writes from multiple processes

Usage

{:ok, ref} = Grove.Storage.DETS.init(file: "/var/lib/grove/crdts.dets")

# Save a CRDT
:ok = Grove.Storage.DETS.save(ref, {:counter, "views"}, crdt_state)

# Load a CRDT
{:ok, crdt_state} = Grove.Storage.DETS.load(ref, {:counter, "views"})

# Close when done
:ok = Grove.Storage.DETS.close(ref)

Options

  • :file - Required. Path to the DETS file
  • :table - Table name (default: :grove_dets_storage)
  • :auto_save - Auto-save interval in ms (default: 60000)

Summary

Functions

Forces a sync of the DETS table to disk.

Functions

sync(table)

@spec sync(atom()) :: :ok | {:error, term()}

Forces a sync of the DETS table to disk.

Normally DETS syncs automatically at the configured interval, but this can be used to force an immediate sync.