EDA.Cache.Guild (EDA v0.3.0)

Copy Markdown View Source

ETS-based cache for Discord guilds.

Provides O(1) lookups for guild data.

Summary

Functions

Gets all cached guilds.

Returns a specification to start this module under a supervisor.

Returns the number of cached guilds.

Creates or replaces a guild in the cache.

Deletes a guild from the cache.

Gets a guild from the cache as a raw map (string keys).

Updates a guild in the cache.

Functions

all()

@spec all() :: [map()]

Gets all cached guilds.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

count()

@spec count() :: non_neg_integer()

Returns the number of cached guilds.

create(guild)

@spec create(map()) :: map()

Creates or replaces a guild in the cache.

delete(guild_id)

@spec delete(String.t() | integer()) :: :ok

Deletes a guild from the cache.

get(guild_id)

@spec get(String.t() | integer()) :: map() | nil

Gets a guild from the cache as a raw map (string keys).

This is the low-level cache accessor. For a typed %EDA.Guild{} struct, use EDA.Guild.fetch/1 instead which parses the raw map automatically.

start_link(opts)

update(guild_id, updates)

@spec update(String.t() | integer(), map()) :: map() | nil

Updates a guild in the cache.