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 primarily for personal projects and has not been battle-tested in large-scale production environments. Plus I am still new to Rust, so contributions, suggestions, and feedback are more than welcome.
Features
-
Expiration of cached item is evaluated lazily.
-
Uses
tokio::sync::RwLockfor async locking. -
Items are stored in a
ShardedMap, which splits the data across multiple shards (HashMaps). This aims to minimize contention points.
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
Example usage
use CrudeCache;