CrudeCache
CrudeCache is a simple utility for good enough concurrent caching needs. Inspired by Play Framework's cache.getOrElseUpdate.
//Returns non-expired cached item. If one does not exist, new item will be cached & returned
cache.get_or_else_update.await
Disclaimer: Please note that CrudeCache was developed for personal projects, it is not battle-tested in production and might contain bugs. Feedback, suggestions, and contributions are more than welcome.
Features
- Expiration of cached items are evaluated lazily.
- To minimize contention points, items are stored in a
ShardedMap, which splits the data across multiple shards (HashMaps). No bells and whistles, and no resharding. - Each shard is behind
tokio::sync::RwLock
Installation
Add this to your Cargo.toml:
[]
= "0.1.1"
Example usage
use CrudeCache;
Similar Crates
More sophisticated alternative: