# `Nebulex.Adapter.Persistence`
[🔗](https://github.com/elixir-nebulex/nebulex/blob/v2.6.6/lib/nebulex/adapter/persistence.ex#L1)

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 to `10`.

  * `compression` - The compression level. The values are the same as
    `:erlang.term_to_binary /2`. Defaults to `6`.

See `c:Nebulex.Cache.dump/2` and `c:Nebulex.Cache.load/2` for more
information.

# `dump`

```elixir
@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 `c:Nebulex.Cache.dump/2`.

# `load`

```elixir
@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 `c:Nebulex.Cache.load/2`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
