#[non_exhaustive]pub struct Sweep {
pub interval: Duration,
pub lifetime: Duration,
}Expand description
A periodic sweep: every interval, remove the entries older than lifetime (D-167).
discord.js counterpart: SweepOptions with interval and filter: Sweepers.filterByLifetime({ lifetime }).
§Examples
use std::time::Duration;
use djs_cache::{CacheConfig, Sweep};
// Every 10 minutes, sweep messages older than 30 minutes.
let config = CacheConfig::builder()
.sweep_messages(Some(Sweep::new(
Duration::from_secs(600),
Duration::from_secs(1_800),
)))
.build();
assert_eq!(config.sweepers().messages.unwrap().lifetime, Duration::from_secs(1_800));Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.interval: DurationHow often the sweep runs.
lifetime: DurationHow old an entry must be to be swept.
Implementations§
Trait Implementations§
impl Copy for Sweep
impl Eq for Sweep
impl StructuralPartialEq for Sweep
Auto Trait Implementations§
impl Freeze for Sweep
impl RefUnwindSafe for Sweep
impl Send for Sweep
impl Sync for Sweep
impl Unpin for Sweep
impl UnsafeUnpin for Sweep
impl UnwindSafe for Sweep
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more