View Source Hologram.Commons.PLT (hologram v0.2.0)
Provides a persistent lookup table (PLT) implemented using ETS (Erlang Term Storage) and GenServer. It allows to store key-value pairs in memory and perform various operations on the data. The data in memory can be dumped to a file and loaded from a file.
Summary
Functions
Returns a specification to start this module under a supervisor.
Returns a clone of the PLT.
Deletes a key-value pair from the PLT.
Serializes the contents of the PLT and writes it to a file.
Returns the value stored in the PLT under the given key. If the key doesn't exist the :error :atom is returned.
Returns the value stored in the PLT under the given key. If the key doesn't exist a KeyError is raised.
Returns all items stored in the PLT.
Returns the reference of the underlying ETS table.
Creates the underlying ETS table.
Populates the PLT with items dumped to the given file.
Populates the PLT with items dumped to the given file if the file exists.
Puts multiple items into the PLT.
Puts the given item into the PLT.
Removes all items from the PLT.
Returns the number of items in the PLT.
Starts the underlying GenServer process.
Stops the underlying GenServer process.
Types
@type t() :: %Hologram.Commons.PLT{ pid: pid() | nil, table_name: atom() | nil, table_ref: Hologram.Commons.ETS.tid() | nil }
Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
Returns a clone of the PLT.
Deletes a key-value pair from the PLT.
Serializes the contents of the PLT and writes it to a file.
Benchmark: https://github.com/bartblast/hologram/blob/master/benchmarks/commons/plt/dump_2/README.md
Returns the value stored in the PLT under the given key. If the key doesn't exist the :error :atom is returned.
Returns the value stored in the PLT under the given key. If the key doesn't exist a KeyError is raised.
Returns all items stored in the PLT.
@spec handle_call(:get_table_ref, GenServer.from(), Hologram.Commons.ETS.tid()) :: {:reply, Hologram.Commons.ETS.tid(), Hologram.Commons.ETS.tid()}
Returns the reference of the underlying ETS table.
@spec init(atom() | nil) :: {:ok, Hologram.Commons.ETS.tid()}
Creates the underlying ETS table.
Populates the PLT with items dumped to the given file.
Populates the PLT with items dumped to the given file if the file exists.
Puts multiple items into the PLT.
Puts the given item into the PLT.
Removes all items from the PLT.
Returns the number of items in the PLT.
@spec start(Hologram.Commons.Types.opts()) :: t()
Starts the underlying GenServer process.
@spec stop(t()) :: :ok
Stops the underlying GenServer process.