| Crates.io | majordome-cache |
| lib.rs | majordome-cache |
| version | 1.0.5 |
| created_at | 2024-05-07 17:09:00.620012+00 |
| updated_at | 2025-08-27 16:02:02.707753+00 |
| description | A cache module for Majordome. Currently based on Moka. |
| homepage | |
| repository | https://github.com/merlleu/majordome |
| max_upload_size | |
| id | 1232408 |
| size | 30,765 |
This crates lets you cache any date in memory with a simple API.
To use it, simply inject MajordomeCache to your majordome App.
Then you can simply get a MajordomeCacheGetter by calling MajordomeCache::key with the key you want to cache.
async fn do_expensive_operation(query: Q) -> Result<R, E> {}
let resp = app
.get::<MajordomeCache>()?
.key(&query)
.ttl(60)
.try_get_with(do_expensive_operation(query))
.await?;
The past example will cache the result of do_expensive_operation for 60 seconds in memory, with a key based on the query.
resp will have Arc