smart-cache 0.2.0

A smart caching library for Rust with automatic invalidation
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use smart_cache_macro::cached;

#[cached]
fn expensive_computation(x: &str, y: i32) -> String {
    use std::{thread, time::Duration};

    thread::sleep(Duration::from_secs(3));

    format!("example computation {x}_{y}")
}

#[test]
fn test_cached() {
    let x = expensive_computation("hello", 2);
    println!("{x}");
}