Crate cache_ro

Source
Expand description

§Persistent Cache for Rust

A high-performance, thread-safe cache with:

  • Optional filesystem persistence
  • Automatic TTL-based cleanup
  • Key-level locking
  • Efficient binary serialization

§Features

  • Thread-safe - Uses DashMap for concurrent access
  • Persistent - Optional filesystem storage
  • TTL Support - Automatic expiration of entries
  • Efficient - bincode serialization

§Examples

§Basic Usage

use cache_ro::{Cache, CacheConfig};
use std::time::Duration;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let cache = Cache::new(CacheConfig::default())?;
    cache.set("key", "value".to_string(), Duration::from_secs(60))?;

    if let Some(value) = cache.get::<String>("key") {
        println!("Retrieved: {}", value);
    }
    Ok(())
}

Structs§

Cache
CacheConfig