EDA.Cache.Config (EDA v0.3.0)

Copy Markdown View Source

Resolves cache configuration at startup and stores it in :persistent_term for O(1) access.

Called once by EDA.Cache.Supervisor before cache processes start.

Example

config :eda,
  cache: [
    guilds: [],
    users: [max_size: 100_000],
    members: [policy: :none],
    presences: [policy: :none],
    channels: [policy: fn _entity, _key, ch ->
      if ch["type"] in [0, 2, 5], do: :cache, else: :skip
    end]
  ]

Summary

Functions

Returns all cache key names.

Returns the full config map for a cache.

Returns the max_size for a cache, or nil if unlimited.

Returns the policy for a cache.

Resolves application config and stores in persistent_term. Idempotent.

Functions

cache_keys()

@spec cache_keys() :: [atom()]

Returns all cache key names.

get(cache_name)

@spec get(atom()) :: map()

Returns the full config map for a cache.

max_size(cache_name)

@spec max_size(atom()) :: non_neg_integer() | nil

Returns the max_size for a cache, or nil if unlimited.

policy(cache_name)

@spec policy(atom()) :: term()

Returns the policy for a cache.

setup()

@spec setup() :: :ok

Resolves application config and stores in persistent_term. Idempotent.