Cache

Trait Cache 

Source
pub trait Cache: Send + Sync {
Show 15 methods // Required methods fn guild(&self, id: Snowflake) -> Option<Arc<Guild<'static>>>; fn channel(&self, id: Snowflake) -> Option<Arc<Channel<'static>>>; fn user(&self, id: Snowflake) -> Option<Arc<User<'static>>>; fn member( &self, guild_id: Snowflake, user_id: Snowflake, ) -> Option<Arc<GuildMember<'static>>>; fn role(&self, id: Snowflake) -> Option<Arc<Role<'static>>>; fn insert_guild(&self, guild: Arc<Guild<'static>>); fn insert_channel(&self, channel: Arc<Channel<'static>>); fn insert_user(&self, user: Arc<User<'static>>); fn insert_member( &self, guild_id: Snowflake, member: Arc<GuildMember<'static>>, ); fn insert_role(&self, id: Snowflake, role: Arc<Role<'static>>); fn remove_guild(&self, id: Snowflake) -> Option<Arc<Guild<'static>>>; fn remove_channel(&self, id: Snowflake) -> Option<Arc<Channel<'static>>>; fn remove_user(&self, id: Snowflake) -> Option<Arc<User<'static>>>; fn remove_member( &self, guild_id: Snowflake, user_id: Snowflake, ) -> Option<Arc<GuildMember<'static>>>; fn remove_role(&self, id: Snowflake) -> Option<Arc<Role<'static>>>;
}
Expand description

Trait for cache implementations.

Implement this trait to provide custom caching backends (e.g., Redis, database). The default implementation is InMemoryCache.

Required Methods§

Source

fn guild(&self, id: Snowflake) -> Option<Arc<Guild<'static>>>

Get a guild by ID.

Source

fn channel(&self, id: Snowflake) -> Option<Arc<Channel<'static>>>

Get a channel by ID.

Source

fn user(&self, id: Snowflake) -> Option<Arc<User<'static>>>

Get a user by ID.

Source

fn member( &self, guild_id: Snowflake, user_id: Snowflake, ) -> Option<Arc<GuildMember<'static>>>

Get a guild member by guild and user ID.

Source

fn role(&self, id: Snowflake) -> Option<Arc<Role<'static>>>

Get a role by ID.

Source

fn insert_guild(&self, guild: Arc<Guild<'static>>)

Insert a guild into the cache.

Source

fn insert_channel(&self, channel: Arc<Channel<'static>>)

Insert a channel into the cache.

Source

fn insert_user(&self, user: Arc<User<'static>>)

Insert a user into the cache.

Source

fn insert_member(&self, guild_id: Snowflake, member: Arc<GuildMember<'static>>)

Insert a guild member into the cache.

Source

fn insert_role(&self, id: Snowflake, role: Arc<Role<'static>>)

Insert a role into the cache.

Source

fn remove_guild(&self, id: Snowflake) -> Option<Arc<Guild<'static>>>

Remove a guild from the cache.

Source

fn remove_channel(&self, id: Snowflake) -> Option<Arc<Channel<'static>>>

Remove a channel from the cache.

Source

fn remove_user(&self, id: Snowflake) -> Option<Arc<User<'static>>>

Remove a user from the cache.

Source

fn remove_member( &self, guild_id: Snowflake, user_id: Snowflake, ) -> Option<Arc<GuildMember<'static>>>

Remove a guild member from the cache.

Source

fn remove_role(&self, id: Snowflake) -> Option<Arc<Role<'static>>>

Remove a role from the cache.

Implementors§