Skip to main content

laterite_core/cache/
null.rs

1//! The `null` store: keeps nothing, so every read loads afresh. Generations
2//! still move and locks still hold.
3
4use std::time::Duration;
5
6use async_trait::async_trait;
7
8use super::{Entry, ValueStore};
9use crate::error::CoreResult;
10
11/// A store that holds nothing.
12#[derive(Debug, Default, Clone, Copy)]
13pub struct NullStore;
14
15#[async_trait]
16impl ValueStore for NullStore {
17    fn name(&self) -> &'static str {
18        "null"
19    }
20    async fn get(&self, _key: &str) -> CoreResult<Option<Entry>> {
21        Ok(None)
22    }
23    async fn put(&self, _key: &str, _entry: Entry, _ttl: Duration) -> CoreResult<()> {
24        Ok(())
25    }
26    async fn add(&self, _key: &str, _entry: Entry, _ttl: Duration) -> CoreResult<bool> {
27        Ok(true)
28    }
29    async fn forget(&self, _key: &str) -> CoreResult<bool> {
30        Ok(false)
31    }
32    async fn flush(&self) -> CoreResult<()> {
33        Ok(())
34    }
35}