ExFPL.Cache (ExFPL v0.1.0)

Copy Markdown View Source

ETS-backed cache with per-entry TTL.

Used by ExFPL.Bootstrap.fetch/1 to avoid re-downloading the ~1 MB bootstrap-static payload on every call. Started under the application supervisor; the underlying ETS table is always available while the application is running.

Summary

Functions

Returns a specification to start this module under a supervisor.

Fetch a value from the cache. Returns {:ok, value} or :miss.

Remove a single key, or all entries when called with :all (default).

Insert a value with an optional TTL in milliseconds (default 1 hour).

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

get(key)

@spec get(term()) :: {:ok, term()} | :miss

Fetch a value from the cache. Returns {:ok, value} or :miss.

invalidate(key \\ :all)

@spec invalidate(term() | :all) :: :ok

Remove a single key, or all entries when called with :all (default).

put(key, value, ttl_ms \\ 3_600_000)

@spec put(term(), term(), non_neg_integer()) :: :ok

Insert a value with an optional TTL in milliseconds (default 1 hour).

start_link(opts \\ [])