API Reference ActiveMemory v0.7.0

modules

Modules

Bring the power of in memory storage with ETS and Mnesia to your Elixir application.

The ActiveRepo

An ActiveRepo manages multiple ActiveMemory.Tables from a single process. It is the multi-table counterpart to ActiveMemory.Store (which manages a single table), giving you one supervised entry point and a unified API over many tables.

An adapter for storing structs in ETS

An adapter for storing structs in Mnesia

Migrations will get run on app startup and are designed to modify :mnesia's schema.

Starts the ActiveMemory supervision tree, which runs the ActiveMemory.TableHeir process that preserves ETS tables across store crashes and restarts.

The shared implementation of the table operations and store setup used by ActiveMemory.Store and ActiveMemory.ActiveRepo.

the-match-query-syntax

The match query syntax

Using the match macro you can structure a basic query.

The Store

store-api

Store API

  • Store.all/0 Get all records stored
  • Store.delete/1 Delete the record provided
  • Store.delete_all/0 Delete all records stored
  • Store.one/1 Get one record matching either an attributes search or match query
  • Store.select/1 Get all records matching either an attributes search or match query
  • Store.withdraw/1 Get one record matching either an attributes search or match query, delete the record and return it
  • Store.write/1 Write a record into the memmory table

concurrency

Concurrency

A Store is a GenServer, but the data functions above (all/0, one/1, select/1, write/1, delete/1, withdraw/1, delete_all/0) are not routed through that process and are not serialized by it. They are ordinary module functions that run in the caller's process, delegating straight to the table's adapter (and therefore to :ets/:mnesia). Concurrency is governed by ETS/Mnesia themselves, so many processes read and write in parallel — the single GenServer is not a bottleneck. Only lifecycle and metadata operations (init, state/0, reload_seeds/0) actually use the GenServer.

Define your table attributes and options.

Stable "owner of last resort" for the ETS tables created by ActiveMemory.Store.