zenmanage 1.0.0

Official Zenmanage feature flags SDK for Rust
Documentation
use std::time::Duration;

use super::{CacheBackend, CacheFuture};

/// No-op cache backend useful for tests and strict no-cache setups.
#[derive(Clone, Debug, Default)]
pub struct NullCache;

impl NullCache {
    /// A cache that keeps nothing.
    pub fn new() -> Self {
        Self
    }
}

impl CacheBackend for NullCache {
    fn get<'a>(&'a self, _key: &'a str) -> CacheFuture<'a, Option<String>> {
        Box::pin(async { Ok(None) })
    }

    fn set<'a>(&'a self, _key: &'a str, _value: String, _ttl: Duration) -> CacheFuture<'a, ()> {
        Box::pin(async { Ok(()) })
    }
}