EDA.Cache.Role (EDA v0.3.0)

Copy Markdown View Source

ETS-based cache for Discord roles.

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

Summary

Functions

Gets all cached roles.

Returns a specification to start this module under a supervisor.

Returns the total number of cached roles.

Creates or replaces a role in the cache.

Deletes a role from the cache.

Removes all roles for a guild.

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

Gets a role by ID.

Updates a role in the cache.

Functions

all()

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

Gets all cached roles.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

count()

@spec count() :: non_neg_integer()

Returns the total number of cached roles.

create(guild_id, role)

@spec create(String.t(), map()) :: map()

Creates or replaces a role in the cache.

delete(role_id)

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

Deletes a role from the cache.

delete_guild(guild_id)

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

Removes all roles for a guild.

for_guild(guild_id)

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

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

get(role_id)

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

Gets a role by ID.

start_link(opts)

update(role_id, updates)

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

Updates a role in the cache.