Normandy.Behaviours.MemoryStore.Mnesia
(normandy v2.2.0)
View Source
Distributed, durable MemoryStore over Mnesia, in an :ordered_set table with
attributes [:key, :value]: one row per document ({namespace, path} → the document)
plus one totals row per namespace ({namespace, 0} → {bytes, documents}). Every
operation is one :mnesia.transaction/1. A write first takes the write lock on its
namespace's totals row, so a namespace's writers run one at a time and compare-and-set,
rename, delete_tree and the put/6 limits are atomic across the cluster. get/3 reads
one row. list/3, delete_tree/3, rename/4 and delete_namespace/2 select the
namespace's rows, which locks the whole table for the transaction (a read lock for
list/3): a rename or tree delete in one namespace briefly holds writes in the others,
and a list/3 waits for a write in progress in any namespace.
The handle is the table name. Create it with create_tables/1 (copies: :disc_copies
by default, for durability; :table defaults to :normandy_memory_documents); new/1
makes a uniquely named ram_copies table for tests. A release using this store must
include :mnesia in extra_applications.
Summary
Functions
Creates the memory table.
Test/default handle: a fresh uniquely named ram_copies table on this node.
Functions
@spec create_tables(keyword()) :: :ok
Creates the memory table.
Options
:table(atom/0) - The table. The default value is:normandy_memory_documents.:copies- Disc or RAM copies. The default value is:disc_copies.:nodes(list ofatom/0) - The nodes holding copies (default:[node()]).:wait_timeout(timeout/0) - How long to wait for the table to load, in ms. The default value is30000.
Test/default handle: a fresh uniquely named ram_copies table on this node.
Options
:table(atom/0) - The table (default: a unique name).