# `Cache.DETS`
[🔗](https://github.com/mikaak/elixir_cache/blob/main/lib/cache/dets.ex#L1)

DETS adapter so that we can use dets as a cache

## Options
* `:ram_file` (`t:boolean/0`) - Enable RAM File The default value is `false`.

* `:type` - Data type of DETS cache The default value is `:set`.

* `:file_path` (`t:String.t/0`) - File path to save DETS file at The default value is `"./"`.

# `child_spec`

Returns a specification to start this module under a supervisor.

`arg` is passed as the argument to `Task.start_link/1` in the `:start` field
of the spec.

For more information, see the `Supervisor` module,
the `Supervisor.child_spec/2` function and the `t:Supervisor.child_spec/0` type.

# `native_term_storage?`

DETS keeps encoding, even though `:dets.insert/2` takes terms and would serialise
them itself.

The reason is the file on disk. Every `.dets` file written by an earlier version of
this library holds `:erlang.term_to_binary/1` blobs as its values. Those files outlive
the upgrade — that is the entire point of a disk cache. If this adapter switched to
native terms, the first read after an upgrade would hand the caller a raw binary where
it expects a term, silently, with no error to trace it back to.

The cost of keeping it is one redundant serialisation of data that is already headed
for a disk write, which is dominated by the I/O. The cost of dropping it is corrupting
every existing on-disk cache. That trade is not close.

---

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