Expand description
Elastic sharded maps and TTL-driven object caches for grafOS.
This crate provides two cache building blocks:
elastic::ElasticShardSet— a set of shards (each backed by aMemLease+FabricHashMap) that can grow and shrink at runtime.ttl::TtlObjectCache— an in-memory object cache with per-entry TTL and poll-driven expiry pruning.
§Quick start
use grafos_cache::elastic::ElasticShardSet;
use grafos_cache::ttl::{TtlObjectCache, CacheStats};
use grafos_leasekit::RenewalPolicy;
// Elastic shard set
let mut shards: ElasticShardSet<u32, u32> =
ElasticShardSet::new(2, 64, 8, 8)?;
shards.put(&1, &100)?;
assert_eq!(shards.get(&1)?, Some(100));
// TTL object cache
let mut cache = TtlObjectCache::<String>::new(RenewalPolicy::default());§Feature flags
| Feature | Default | Effect |
|---|---|---|
std | Yes | Enables std in grafos-std (thread-local mock state) |
observe | No | Optional grafos-observe integration |