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:
Supervised Mode (Recommended for Production &
async: trueTests): Add{JevDSL.Cache.ETS, name: MyApp.JevCache, table: :my_app_jev_cache}to your application's supervision tree (orstart_supervised!/1in tests). The GenServer owns the ETS table and periodically prunes expired keys.Zero-Config On-Demand Mode: If
get/2orput/3is called before a server is started,ensure_table/1creates the named ETS table and attaches a lightweight heir receiver so the table survives even if the first caller was a short-livedTaskor request process.
Summary
Functions
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.
Clears all cached entries in the ETS cache table.
Deletes all expired entries from table and returns the number of evicted keys.
Starts an ETS cache owner process linked to the caller's supervision tree.
Functions
@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.
@spec clear(atom()) :: :ok
Clears all cached entries in the ETS cache table.
@spec prune_expired(atom()) :: non_neg_integer()
Deletes all expired entries from table and returns the number of evicted keys.
@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 isJevDSL.Cache.ETS.:table(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 is300000.