pub struct InMemoryCache { /* private fields */ }
Expand description
An in-memory cache of Revolt data.
To use a cache instance in multiple tasks, consider wrapping it in an
std::sync::Arc
or std::rc::Rc
.
Implementations§
Source§impl InMemoryCache
impl InMemoryCache
Sourcepub fn new() -> Self
pub fn new() -> Self
Create new InMemoryCache
instance with default Config
.
Sourcepub fn new_with_config(config: Config) -> Self
pub fn new_with_config(config: Config) -> Self
Create new InMemoryCache
instance with provided Config
.
Sourcepub const fn builder() -> InMemoryCacheBuilder
pub const fn builder() -> InMemoryCacheBuilder
Create a new builder to configure and construct an in-memory cache.
Sourcepub const fn stats(&self) -> InMemoryCacheStats<'_>
pub const fn stats(&self) -> InMemoryCacheStats<'_>
Create an interface for retrieving cache statistics.
Example:
use rive_cache_inmemory::InMemoryCache;
let cache = InMemoryCache::new();
// later in the code...
let messages = cache.stats().messages();
println!("messages count: {messages}");
Sourcepub const fn iter(&self) -> InMemoryCacheIter<'_>
pub const fn iter(&self) -> InMemoryCacheIter<'_>
Create an interface for iterating over the various resources in the cache.
Example:
use rive_cache_inmemory::InMemoryCache;
let cache = InMemoryCache::new();
// later in the code...
for user in cache.iter().users() {
println!("{}: {}#{}", user.id, user.username, user.discriminator);
}
Sourcepub fn member(
&self,
id: &MemberCompositeKey,
) -> Option<Reference<'_, MemberCompositeKey, Member>>
pub fn member( &self, id: &MemberCompositeKey, ) -> Option<Reference<'_, MemberCompositeKey, Member>>
Get a member by MemberCompositeKey
.
Trait Implementations§
Source§impl Debug for InMemoryCache
impl Debug for InMemoryCache
Source§impl Default for InMemoryCache
impl Default for InMemoryCache
Source§fn default() -> InMemoryCache
fn default() -> InMemoryCache
Returns the “default value” for a type. Read more
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