Skip to content

r-cache is an in memory key value store. It is thread safe and values can have expiry times.

Notifications You must be signed in to change notification settings

simplecastapps/r-cache

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

r-cache

A simple caching library


r-cache is an in memory key value store. It is thread safe and values can have expiry times.

Example

use async_std::sync::Arc;
use async_std::task;
use r_cache::cache::Cache;
use std::time::Duration;

const KEY: i8 = 0;
const VALUE: &str = "VALUE";

#[async_std::main]
async fn main() {
    let cache = Arc::new(Cache::new(Some(Duration::from_secs(5 * 60))));
    task::spawn({
        let cache = Arc::clone(&cache);
        async move {
            loop {
                task::sleep(Duration::from_secs(10 * 60)).await;
                cache.remove_expired().await;
            }
        }
    });

    cache.set(KEY, VALUE, None).await;

    assert_eq!(VALUE, cache.get(&KEY).await.unwrap())
}

About

r-cache is an in memory key value store. It is thread safe and values can have expiry times.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%