Skip to content

A basic and simple Rust library async/await ready caching implementation for structures.

License

Notifications You must be signed in to change notification settings

Emulator000/simple-cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Cache

Crates.io License: MIT

A basic and simple Rust library async/await ready caching implementation for structures.

Usage

use simple_cache::{Cache, CacheItem};

struct Object {
    value: i32,
    string: String,
}

impl CacheItem for Object {}

#[tokio::main]
async fn main() {
    let cache = Cache::new();
    let object = Object {
        value: 1,
        string: String::from("test!"),
    };

    let _ = cache.insert("test", Some(object));

    let cached_object = cache.get::<Object, _>("test").unwrap().unwrap().unwrap();
    
    if cached_object.value == 1 {
        println!("Hi from Simple Cache!");
    }
}

About

A basic and simple Rust library async/await ready caching implementation for structures.

Topics

Resources

License

Stars

Watchers

Forks

Languages