[−][src]Crate twilight_cache_inmemory
twilight-cache-inmemory
twilight-cache-inmemory
is an in-process-memory cache for the
[twilight-rs
] ecosystem. It's responsible for processing events and
caching things like guilds, channels, users, and voice states.
Examples
Update a cache with events that come in through the gateway:
use std::env; use tokio::stream::StreamExt; use twilight_cache_inmemory::InMemoryCache; use twilight_gateway::Shard; let token = env::var("DISCORD_TOKEN")?; let mut shard = Shard::new(token); shard.start().await?; // Create a cache, caching up to 10 messages per channel: let cache = InMemoryCache::builder().message_cache_size(10).build(); let mut events = shard.events(); while let Some(event) = events.next().await { // Update the cache with the event. cache.update(&event); }
License
All first-party crates are licensed under ISC
Modules
model | Models built for utilizing efficient caching. |
Structs
Config | Configuration for an |
EventType | Bitflags to filter what event types to process in the cache. |
InMemoryCache | A thread-safe, in-memory-process cache of Discord data. It can be cloned and sent to other threads. |
InMemoryCacheBuilder | Builder to configure and construct an |
Traits
UpdateCache |