API Reference ActiveMemory v0.8.2
modules
Modules
The typed, attribute-queryable in memory store for ETS and Mnesia.
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.
Finds database tables whose workload — read constantly, written rarely — makes
them candidates for an ActiveMemory.Table.
Raised by one/1, one!/1, get_by/1 and get_by!/1 when a query intended to
match a single record matches more than one.
Raised by the bang variants of the read functions (get!/1, get_by!/1,
one!/1, reload!/1) when no record matches.
The shared implementation of the table operations and store setup used by
ActiveMemory.Store and ActiveMemory.ActiveRepo.
The match/1 macro, for queries that need more than equality.
The Store
store-api
Store API
Store.all/1Get all records stored, optionally ordered and paged (see Ordering and paging)Store.count/1Count the records stored, without reading them (see Counting)Store.delete/1Delete the record provided, matched in full (see Deleting a record)Store.delete_all/0Delete all records storedStore.exists?/2Whether any record matches an attributes search ormatchqueryStore.get/1Get the record with the given primary key, or{:error, :not_found}Store.get!/1Likeget/1but raisesActiveMemory.NotFoundErrorStore.get_by/1Get the single record matching an attributes searchStore.get_by!/1Likeget_by/1but raisesActiveMemory.NotFoundErrorStore.one/1Get one record matching either an attributes search ormatchquery. RaisesActiveMemory.MultipleResultsErrorwhen several matchStore.one!/1Likeone/1but raisesActiveMemory.NotFoundErrorStore.reload/1Re-read a record from the table by its primary keyStore.reload!/1Likereload/1but raisesActiveMemory.NotFoundErrorStore.select/2Get all records matching either an attributes search ormatchquery, optionally ordered and pagedStore.withdraw/1Atomically get one record matching either an attributes search ormatchquery, delete the record and return it — exactly one concurrent caller wins, making it safe for take-once workloadsStore.write/1Write a record into the memory table, from a struct or anEcto.Changeset. An invalid changeset is returned as{:error, changeset}with itsactionset to:insert, exactly likeEcto.Repo.insert/2
reading-a-single-record
Reading a single record
get/1 reads by primary key — the table's first field, which is what ETS and
Mnesia key a record on. That is :uuid on a table using
auto_generate_uuid: true, an Ecto schema's declared primary key, or simply the
first field declared.
Define your table attributes and options.
Stable "owner of last resort" for the ETS tables created by ActiveMemory.Store.
mix-tasks
Mix Tasks
Reads your database's own table statistics through the application's Ecto repo
and reports which tables have the high-read, low-write workload that makes them
candidates for an ActiveMemory.Table.