View Source PropertyTable.Persist (property_table v0.2.3)

This module contains logic to persist the content of a PropertyTable to disk

It does so in the following manner:

  1. If a prop_table.db file exists in the data directory, rename it to prop_table.db.backup
  2. Write the data of the ETS table to the file prop_table.db
  3. Delete the backup file

When you wish to restore a property table from disk, the following will occur:

  1. The stable file will be verified, if it validates, it will be loaded
  2. If the stable file failed to validate or did not exist, try and load from the last backup file
  3. If the backup file fails, log loudly about data loss

You can also manually request "snapshots" of the property table, this will immediately do the procedure for persisting to disk above, then a duplicate of the current prop_table.db file will be copied into the snapshots/ directory with a timestamp added to the file name. max_snapshots in the options keyword list can be used to limit the number of snapshots saved in the snapshots/ directory, if the limit is reached during a snapshot operation, the oldest snapshot will be deleted from disk.

Link to this section Summary

Link to this section Functions

Link to this function

get_snapshot_list(options)

View Source
@spec get_snapshot_list(Keyword.t()) :: [{String.t(), tuple()}] | no_return()
Link to this function

persist_to_disk(table, options)

View Source
@spec persist_to_disk(reference() | atom(), Keyword.t()) :: :ok | :error | no_return()
Link to this function

restore_from_disk(table, options)

View Source
@spec restore_from_disk(reference() | atom(), Keyword.t()) :: :ok | {:error, atom()}
Link to this function

restore_snapshot(options, snapshot_id)

View Source
@spec restore_snapshot(Keyword.t(), String.t()) ::
  :ok | {:error, atom()} | no_return()
Link to this function

save_snapshot(table, options)

View Source
@spec save_snapshot(reference() | atom(), Keyword.t()) ::
  {:ok, String.t()} | :error | no_return()