EDA.Cache.Evictor (EDA v0.3.0)

Copy Markdown View Source

Periodic LRW (Least Recently Written) evictor for caches with max_size.

Shadow ETS tables track write timestamps only for caches that have a configured max_size. Caches without max_size incur zero overhead.

Every @interval ms, the evictor checks each evictable cache and removes the oldest entries when the main table exceeds its limit.

Example

config :eda,
  cache: [
    users: [max_size: 100_000]
  ]

Summary

Functions

Returns a specification to start this module under a supervisor.

Removes a key from the shadow tables. Called by cache modules on delete. No-op if the cache has no max_size configured.

Records a write in the shadow tables. Called by cache modules on create/upsert. No-op if the cache has no max_size configured. Direct ETS ops, non-blocking.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

remove(table, key)

@spec remove(atom(), term()) :: :ok

Removes a key from the shadow tables. Called by cache modules on delete. No-op if the cache has no max_size configured.

start_link(opts)

touch(table, key)

@spec touch(atom(), term()) :: :ok

Records a write in the shadow tables. Called by cache modules on create/upsert. No-op if the cache has no max_size configured. Direct ETS ops, non-blocking.