simple-cache

Crates.iosimple-cache
lib.rssimple-cache
version0.2.0
sourcesrc
created_at2020-09-25 16:35:30.82001
updated_at2021-05-30 17:04:17.853131
descriptionA basic and simple Rust library async/await ready caching implementation for structures.
homepage
repositoryhttps://github.com/Emulator000/simple-cache
max_upload_size
id292882
size7,858
Dario (Emulator000)

documentation

README

Simple Cache

Crates.io Build Status 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!");
    }
}
Commit count: 14

cargo fmt