EDA.Cache.Channel (EDA v0.3.0)

Copy Markdown View Source

ETS-based cache for Discord channels.

Uses composite keys {guild_id, channel_id} for O(guild_size) lookups via for_guild/1 instead of full table scans. A reverse index table maps channel_id to guild_id for efficient single-channel lookups.

DM channels use nil as their guild_id.

Summary

Functions

Gets all cached channels.

Returns a specification to start this module under a supervisor.

Returns the number of cached channels.

Creates or replaces a channel in the cache.

Deletes a channel from the cache.

Removes all channels for a guild.

Gets all channels for a guild. O(guild_size) via match_object.

Gets a channel from the cache by channel ID.

Updates a channel in the cache.

Functions

all()

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

Gets all cached channels.

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 channels.

create(channel)

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

Creates or replaces a channel in the cache.

delete(channel_id)

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

Deletes a channel from the cache.

delete_guild(guild_id)

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

Removes all channels for a guild.

for_guild(guild_id)

@spec for_guild(String.t() | integer()) :: [map()]

Gets all channels for a guild. O(guild_size) via match_object.

get(channel_id)

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

Gets a channel from the cache by channel ID.

start_link(opts)

update(channel_id, updates)

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

Updates a channel in the cache.