soph_cache/support/drivers/
null.rs1use crate::{async_trait, error::Error, traits::CacheDriver, CacheResult};
2
3pub struct Null;
4
5pub fn new() -> Box<dyn CacheDriver> {
6 Box::new(Null {})
7}
8
9#[async_trait]
10impl CacheDriver for Null {
11 async fn has(&self, _key: &str) -> CacheResult<bool> {
12 Err(Error::Message("Operation not supported by null cache".into()))
13 }
14
15 async fn get(&self, _key: &str) -> CacheResult<Option<String>> {
16 Ok(None)
17 }
18
19 async fn insert(&self, _key: &str, _value: &str) -> CacheResult<()> {
20 Err(Error::Message("Operation not supported by null cache".into()))
21 }
22
23 async fn remove(&self, _key: &str) -> CacheResult<()> {
24 Err(Error::Message("Operation not supported by null cache".into()))
25 }
26 async fn clear(&self) -> CacheResult<()> {
27 Err(Error::Message("Operation not supported by null cache".into()))
28 }
29}