pub struct InMemoryCache { /* private fields */ }Expand description
In-memory cache for Discord entities with Time-To-Live (TTL).
Uses DashMap for lock-free concurrent access. All stored values
are wrapped in Arc for efficient sharing.
§TTL Behavior
- Default TTL is 1 hour
- Expired items are filtered out on read
- Call
InMemoryCache::sweepto remove expired items and free memory
Implementations§
Trait Implementations§
Source§impl Cache for InMemoryCache
impl Cache for InMemoryCache
Source§fn member(
&self,
guild_id: Snowflake,
user_id: Snowflake,
) -> Option<Arc<GuildMember<'static>>>
fn member( &self, guild_id: Snowflake, user_id: Snowflake, ) -> Option<Arc<GuildMember<'static>>>
Get a guild member by guild and user ID.
Source§fn insert_guild(&self, guild: Arc<Guild<'static>>)
fn insert_guild(&self, guild: Arc<Guild<'static>>)
Insert a guild into the cache.
Source§fn insert_channel(&self, channel: Arc<Channel<'static>>)
fn insert_channel(&self, channel: Arc<Channel<'static>>)
Insert a channel into the cache.
Source§fn insert_user(&self, user: Arc<User<'static>>)
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>>)
fn insert_member(&self, guild_id: Snowflake, member: Arc<GuildMember<'static>>)
Insert a guild member into the cache.
Source§fn remove_guild(&self, id: Snowflake) -> Option<Arc<Guild<'static>>>
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>>>
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>>>
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>>>
fn remove_member( &self, guild_id: Snowflake, user_id: Snowflake, ) -> Option<Arc<GuildMember<'static>>>
Remove a guild member from the cache.
Auto Trait Implementations§
impl Freeze for InMemoryCache
impl !RefUnwindSafe for InMemoryCache
impl Send for InMemoryCache
impl Sync for InMemoryCache
impl Unpin for InMemoryCache
impl UnwindSafe for InMemoryCache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more