serenity/cache/
settings.rs

1use std::time::Duration;
2
3/// Settings for the cache.
4///
5/// # Examples
6///
7/// Create new settings, specifying the maximum number of messages:
8///
9/// ```rust
10/// use serenity::cache::Settings as CacheSettings;
11///
12/// let mut settings = CacheSettings::default();
13/// settings.max_messages = 10;
14/// ```
15#[cfg_attr(feature = "typesize", derive(typesize::derive::TypeSize))]
16#[derive(Clone, Debug)]
17#[non_exhaustive]
18pub struct Settings {
19    /// The maximum number of messages to store in a channel's message cache.
20    ///
21    /// Defaults to 0.
22    pub max_messages: usize,
23    /// How long temporarily-cached data should be stored before being thrown out.
24    ///
25    /// Defaults to one hour.
26    pub time_to_live: Duration,
27    /// Whether to cache guild data received from gateway.
28    ///
29    /// Defaults to true.
30    pub cache_guilds: bool,
31    /// Whether to cache channel data received from gateway.
32    ///
33    /// Defaults to true.
34    pub cache_channels: bool,
35    /// Whether to cache user data received from gateway.
36    ///
37    /// Defaults to true.
38    pub cache_users: bool,
39}
40
41impl Default for Settings {
42    fn default() -> Self {
43        Self {
44            max_messages: 0,
45            time_to_live: Duration::from_secs(60 * 60),
46            cache_guilds: true,
47            cache_channels: true,
48            cache_users: true,
49        }
50    }
51}