# `JevDSL.Cache.ETS`
[🔗](https://github.com/boxxxie/jev_dsl/blob/v0.1.0/lib/jev_dsl/cache/ets.ex#L1)

Built-in zero-dependency ETS cache adapter implementing `JevDSL.Cache`.

Provides concurrent read/write access with monotonic TTL expiration so `JevDSL`
works out of the box in any Elixir application without external cache dependencies.

## Supervision & ETS Table Ownership

`JevDSL.Cache.ETS` can be used in two modes:

1. **Supervised Mode (Recommended for Production & `async: true` Tests):**
   Add `{JevDSL.Cache.ETS, name: MyApp.JevCache, table: :my_app_jev_cache}` to your
   application's supervision tree (or `start_supervised!/1` in tests). The GenServer
   owns the ETS table and periodically prunes expired keys.

2. **Zero-Config On-Demand Mode:**
   If `get/2` or `put/3` is called before a server is started, `ensure_table/1`
   creates the named ETS table and attaches a lightweight heir receiver so the table
   survives even if the first caller was a short-lived `Task` or request process.

# `child_spec`

```elixir
@spec child_spec(keyword()) :: Supervisor.child_spec()
```

Returns a child specification with `:id` scoped to `:name` or `:table` so multiple
`JevDSL.Cache.ETS` instances can be supervised in the same tree or test.

# `clear`

```elixir
@spec clear(atom()) :: :ok
```

Clears all cached entries in the ETS cache table.

# `prune_expired`

```elixir
@spec prune_expired(atom()) :: non_neg_integer()
```

Deletes all expired entries from `table` and returns the number of evicted keys.

# `start_link`

```elixir
@spec start_link(keyword()) :: GenServer.on_start()
```

Starts an ETS cache owner process linked to the caller's supervision tree.

## Options

* `:name` - Process registration name for the ETS owner server. The default value is `JevDSL.Cache.ETS`.

* `:table` (`t:atom/0`) - Named ETS table atom. The default value is `:jev_dsl_ets_cache`.

* `:cleanup_interval` - Interval in milliseconds between automatic expired-entry sweeps. The default value is `300000`.

---

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