4.13 Module classy_table

This module implements a standalone minimalist analogue of mnesia’s local_data table with disc_copies storage.

It is used to store classy’s own persistent data. Other applications can also use it for data that doesn’t require replication and is not written too frequently.

4.14 Implementation

Classy tables consist of a RAM cache backed by ETS and a durable write ahead log. Durable operations (write, delete, atomically) are immediately appended to the WAL, while dirty mutations (dirty_write, dirty_delete) only mark certain keys as dirty. All dirtied keys are flushed to WAL only when table is flushed.

The WAL is periodically compacted when its “badness” exceeds the configured threshold. Badness is calculated as a difference between the number of table elements and length of the log. WAL compaction is a blocking operation: all table mutations get blocked while it goes on. Compaction time is proportional to the number of elements stored in the table.

Because of this design, frequent mutations of the same key, e.g.

classy_table:write(Tab, foo, 1),
classy_table:write(Tab, foo, 2),
classy_table:write(Tab, foo, 3),
...

are rather inefficient.

4.15 Limitations


JavaScript license information