pub struct InMemoryCacheStats<'a>(/* private fields */);
Expand description
Retrieve statistics about the number of entities of each resource in the cache.
Statistics can be retrieved about the amount of resources on a cache-level
via a method such as users
or in a particular channel via a method
such as channel_messages
.
Examples
Retrieve the number of users stored in the cache:
use twilight_cache_inmemory::InMemoryCache;
let cache = InMemoryCache::new();
// later on...
println!("user count: {}", cache.stats().users());
Implementations§
source§impl<'a> InMemoryCacheStats<'a>
impl<'a> InMemoryCacheStats<'a>
sourcepub const fn cache_ref(&'a self) -> &'a InMemoryCache
pub const fn cache_ref(&'a self) -> &'a InMemoryCache
Return an immutable reference to the underlying cache.
sourcepub const fn into_cache(self) -> &'a InMemoryCache
pub const fn into_cache(self) -> &'a InMemoryCache
Consume the statistics interface, returning the underlying cache reference.
sourcepub fn channel_messages(&self, channel_id: Id<ChannelMarker>) -> Option<usize>
pub fn channel_messages(&self, channel_id: Id<ChannelMarker>) -> Option<usize>
Number of messages in a given channel in the cache.
Returns None
if the channel hasn’t yet been cached or there are no
messages in the channel. However, the provided number may still be 0
if some number is returned.
sourcepub fn channel_voice_states(
&self,
channel_id: Id<ChannelMarker>
) -> Option<usize>
pub fn channel_voice_states( &self, channel_id: Id<ChannelMarker> ) -> Option<usize>
Number of voice states in a given channel in the cache.
Returns None
if the channel hasn’t yet been cached or there are no
voice states in the channel. However, the provided number may still be 0
if some number is returned.
sourcepub fn guild_channels(&self, guild_id: Id<GuildMarker>) -> Option<usize>
pub fn guild_channels(&self, guild_id: Id<GuildMarker>) -> Option<usize>
Number of channels in a given guild in the cache.
Returns None
if the guild hasn’t yet been cached.
sourcepub fn guild_emojis(&self, guild_id: Id<GuildMarker>) -> Option<usize>
pub fn guild_emojis(&self, guild_id: Id<GuildMarker>) -> Option<usize>
Number of emojis in a given guild in the cache.
Returns None
if the guild hasn’t yet been cached.
sourcepub fn guild_members(&self, guild_id: Id<GuildMarker>) -> Option<usize>
pub fn guild_members(&self, guild_id: Id<GuildMarker>) -> Option<usize>
Number of members in a given guild in the cache.
Returns None
if the guild hasn’t yet been cached.
sourcepub fn guild_presences(&self, guild_id: Id<GuildMarker>) -> Option<usize>
pub fn guild_presences(&self, guild_id: Id<GuildMarker>) -> Option<usize>
Number of presences in a given guild in the cache.
Returns None
if the guild hasn’t yet been cached.
sourcepub fn guild_roles(&self, guild_id: Id<GuildMarker>) -> Option<usize>
pub fn guild_roles(&self, guild_id: Id<GuildMarker>) -> Option<usize>
Number of roles in a given guild in the cache.
Returns None
if the guild hasn’t yet been cached.
sourcepub fn guild_voice_states(&self, guild_id: Id<GuildMarker>) -> Option<usize>
pub fn guild_voice_states(&self, guild_id: Id<GuildMarker>) -> Option<usize>
Number of voice states in a given guild in the cache.
Returns None
if the guild hasn’t yet been cached.
Number of unavailable guilds in the cache.
sourcepub fn voice_states(&self) -> usize
pub fn voice_states(&self) -> usize
Number of voice states in the cache.
Trait Implementations§
source§impl<'a> Clone for InMemoryCacheStats<'a>
impl<'a> Clone for InMemoryCacheStats<'a>
source§fn clone(&self) -> InMemoryCacheStats<'a>
fn clone(&self) -> InMemoryCacheStats<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more