SystemOneDSL.Cache.ETS (SystemOneDSL v1.0.0)

Copy Markdown View Source

Built-in zero-dependency ETS cache adapter implementing SystemOneDSL.Cache.

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

Summary

Functions

Returns a child specification with :id scoped to :name or :table so multiple SystemOneDSL.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

child_spec(init_arg)

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

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

clear(table \\ :system_one_dsl_ets_cache)

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

Clears all cached entries in the ETS cache table.

prune_expired(table \\ :system_one_dsl_ets_cache)

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

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

start_link(opts \\ [])

@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 SystemOneDSL.Cache.ETS.

  • :table (atom/0) - Named ETS table atom. The default value is :system_one_dsl_ets_cache.

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