spawn-access-control 0.1.12

A Rust library for access control management with WebAssembly support, including role-based access control (RBAC), permissions, and audit logging.
Documentation
use moka::sync::Cache;
use std::time::Duration;

pub struct OptimizedCache {
    cache: Cache<String, bool>,
}

impl OptimizedCache {
    pub fn new(max_capacity: u64) -> Self {
        Self {
            cache: Cache::builder()
                .max_capacity(max_capacity)
                .time_to_live(Duration::from_secs(3600))
                .build()
        }
    }

    pub fn get(&self, key: &str) -> Option<bool> {
        self.cache.get(key)
    }

    pub fn insert(&self, key: String, value: bool) {
        self.cache.insert(key, value);
    }
}