View Source Nebulex.Adapter.Persistence behaviour (Nebulex v2.6.4)
Specifies the adapter persistence API.
Default implementation
This module provides a default implementation that uses File
and Stream
under-the-hood. For dumping a cache to a file, the entries are streamed from
the cache and written in chunks (one chunk per line), and each chunk contains
N number of entries. For loading the entries from a file, the file is read
and streamed line-by-line, so that the entries collected on each line are
inserted in streaming fashion as well.
The default implementation accepts the following options only for dump
operation (there are not options for load
):
entries_per_line
- The number of entries to be written per line in the file. Defaults to10
.compression
- The compression level. The values are the same as:erlang.term_to_binary /2
. Defaults to6
.
See Nebulex.Cache.dump/2
and Nebulex.Cache.load/2
for more
information.
Summary
Callbacks
@callback dump(Nebulex.Adapter.adapter_meta(), Path.t(), Nebulex.Cache.opts()) :: :ok | {:error, term()}
Dumps a cache to the given file path
.
Returns :ok
if successful, or {:error, reason}
if an error occurs.
See Nebulex.Cache.dump/2
.
@callback load(Nebulex.Adapter.adapter_meta(), Path.t(), Nebulex.Cache.opts()) :: :ok | {:error, term()}
Loads a dumped cache from the given path
.
Returns :ok
if successful, or {:error, reason}
if an error occurs.
See Nebulex.Cache.load/2
.