Expand description
Cache module for guild channels.
This module provides caching functionality for guild channels and roles using moka cache. It includes three caches:
GUILD_CHANNEL_LIST_CACHE: Caches the list of channels for each guild.GUILD_CHANNEL_CACHE: Caches individual guild channels.GUILD_ROLE_CACHE: Caches the permissions of each role in a guild.
The CacheArgs struct is used to retrieve channels from the cache or fetch them from the API if not found.
Re-exportsΒ§
use anyhow::Context as _;πuse moka::future::Cache;πuse moka::future::CacheBuilder;πuse moka::ops::compute::Op;πuse std::collections::HashMap;πuse std::sync::LazyLock;πuse std::sync::Mutex;πuse std::sync::PoisonError;πuse twilight_http::Client;πuse twilight_model::channel::Channel;πuse twilight_model::guild::Permissions;πuse twilight_model::id::Id;πuse twilight_model::id::marker::ChannelMarker;πuse twilight_model::id::marker::GuildMarker;πuse twilight_model::id::marker::RoleMarker;π
StructsΒ§
- Cache
Args - Arguments for cache operations.
- Stamped
- Channel data together with the generation of its guild it was read under.
StaticsΒ§
- GUILD_
CHANNEL_ CACHE - Cache for individual guild channels, mapping channel IDs to their channel data.
- GUILD_
CHANNEL_ πGENERATIONS - How many channel changes Discord has reported for each guild.
- GUILD_
CHANNEL_ LIST_ CACHE - Cache for guild channel lists, mapping guild IDs to their channel lists.
- GUILD_
ROLE_ CACHE - Cache for role permissions, mapping guild IDs to each roleβs base permissions.
FunctionsΒ§
- advance_
channel_ πgeneration - belongs_
to_ πguild - Returns
truewhen a channel resolved from cache is really inguild_id. - bounded_
cache π - Builds a cache with the shared tuning for every cache in this module: 500 entries, TTL 1 hour, TTI 1 hour.
- channel_
generation π - invalidate_
channel - Drops every cached view of
channel_id. - invalidate_
guild_ roles - Drops the cached role permissions of
guild_id. - role_
permissions - Returns the base permissions of every role in
guild_id, from cache or the Discord API.
Type AliasesΒ§
- Channel
Map - Every channel of a guild, by ID.
- Role
Permissions - The base permissions of every role in a guild, by ID.