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

ETS (Erlang Term Storage) adapter for high-performance in-memory caching.

This adapter provides a fast, process-independent cache using Erlang's built-in ETS tables.
It's ideal for applications requiring low-latency access to cached data within a single node.

## Features

* In-memory storage with configurable concurrency options
* Direct access to ETS-specific operations
* Very high performance for read and write operations
* Support for atomic counter operations

## Options
* `:write_concurrency` - Enable write concurrency

* `:read_concurrency` (`t:boolean/0`) - Enable read concurrency

* `:decentralized_counters` (`t:boolean/0`) - Use decentralized counters

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

* `:compressed` (`t:boolean/0`) - Enable ets compression

* `:rehydration_path` (`t:String.t/0`) - Path to store the ETS table on exit and rehydrate on startup

## Example

```elixir
defmodule MyApp.Cache do
  use Cache,
    adapter: Cache.ETS,
    name: :my_app_cache,
    opts: [
      read_concurrency: true,
      write_concurrency: true
    ]
end
```

# `all`

# `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.

# `delete_all_objects`

# `delete_object`

# `delete_table`

# `file2tab`

# `file2tab`

# `first`

# `first_lookup`

# `foldl`

# `foldr`

# `from_dets`

# `give_away`

# `info`

# `info`

# `init_table`

# `insert_new`

# `insert_raw`

# `is_compiled_ms`

# `last`

# `last_lookup`

# `lookup`

# `lookup_element`

# `lookup_element`

# `match_delete`

# `match_object`

# `match_object`

# `match_pattern`

# `match_pattern`

# `match_spec_compile`

# `match_spec_run`

# `member`

# `native_term_storage?`

`:ets.insert/2` stores terms, so encoding is pure overhead — and it actively breaks
the raw ETS API this adapter exposes (`match_object/1`, `select/1`, `tab2list/0`,
`foldl/2`), which sees opaque binaries instead of the terms that were put.

The exception is `:rehydration_path`. That option dumps the table to disk with
`:ets.tab2file/2` and reads it back on the next boot, so the table is a durable
format. Encoding is kept there for the same reason it is kept for `Cache.DETS`:
a table dumped by an older version holds `term_to_binary/1` blobs, and switching to
native terms would hand callers raw binaries where they expect terms.

# `next`

# `next_lookup`

# `opts_definition`

# `prev`

# `prev_lookup`

# `rename`

# `repair_continuation`

# `safe_fixtable`

# `select`

# `select`

# `select_count`

# `select_delete`

# `select_replace`

# `select_reverse`

# `select_reverse`

# `setopts`

# `slot`

# `tab2file`

# `tab2file`

# `tab2list`

# `tabfile_info`

# `table`

# `table`

# `take`

# `test_ms`

# `to_dets`

# `update_counter`

# `update_counter`

# `update_element`

# `update_element`

# `whereis`

---

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