Skip to main content

Module cache

Module cache 

Source
Expand description

Cache module for guild channels.

This module provides caching functionality for guild channels and roles using moka cache. It includes three caches:

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Β§

CacheArgs
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 true when a channel resolved from cache is really in guild_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Β§

ChannelMap
Every channel of a guild, by ID.
RolePermissions
The base permissions of every role in a guild, by ID.