pub struct InMemoryCacheStats<'a, CacheModels: CacheableModels = DefaultCacheModels>(/* 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::DefaultInMemoryCache;
let cache = DefaultInMemoryCache::new();
// later on...
println!("user count: {}", cache.stats().users());
Implementations§
Source§impl<'a, CacheModels: CacheableModels> InMemoryCacheStats<'a, CacheModels>
impl<'a, CacheModels: CacheableModels> InMemoryCacheStats<'a, CacheModels>
Sourcepub const fn cache_ref(&'a self) -> &'a InMemoryCache<CacheModels>
pub const fn cache_ref(&'a self) -> &'a InMemoryCache<CacheModels>
Return an immutable reference to the underlying cache.
Sourcepub const fn into_cache(self) -> &'a InMemoryCache<CacheModels>
pub const fn into_cache(self) -> &'a InMemoryCache<CacheModels>
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, CacheModels: Clone + CacheableModels> Clone for InMemoryCacheStats<'a, CacheModels>
impl<'a, CacheModels: Clone + CacheableModels> Clone for InMemoryCacheStats<'a, CacheModels>
Source§fn clone(&self) -> InMemoryCacheStats<'a, CacheModels>
fn clone(&self) -> InMemoryCacheStats<'a, CacheModels>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more