| Crates.io | rusticache |
| lib.rs | rusticache |
| version | 0.1.0 |
| created_at | 2022-09-03 14:50:29.937086+00 |
| updated_at | 2022-09-09 15:06:10.75938+00 |
| description | Simple caching for rust without external requirements. |
| homepage | https://github.com/bleikurr/rusticache |
| repository | https://github.com/bleikurr/rusticache |
| max_upload_size | |
| id | 657917 |
| size | 13,223 |
Cache library to be used in async or singlethreaded(not implemented) context.
use std::sync::Arc;
use rusticache::AsyncCache;
use std::time::Duration;
async fn do_stuff() {
let cache = Arc::new(AsyncCache::new(
Duration::from_secs(10),
Box::new(|| Ok(String::from("This is Sparta!")))
));
let data = cache.get_data().await;
assert_eq!(*data.unwrap(), String::from("This is Sparta!"));
}
do_stuff();