- Implemented PanicTracker to log panics using tracing within a dedicated span. - Introduced PanicInfo struct to capture panic details. - Added tests for panic catching and hook restoration. feat: implement token-bucket rate limiter - Created RateLimiter to manage token consumption with configurable rates and burst capacity. - Added methods for acquiring tokens and checking available tokens. - Included tests for rate limiting behavior and token availability. feat: add automatic retry with exponential backoff - Developed retry function to handle transient errors with configurable retry strategies. - Introduced RetryConfig for customizing retry behavior and jitter. - Added tests for various retry scenarios and error handling. feat: implement graceful shutdown coordination - Created ShutdownManager to manage shutdown signals and task completion. - Introduced ShutdownSignal for tasks to observe shutdown requests. - Added tests for shutdown request handling and task draining. feat: add timeout functionality for async operations - Implemented with_timeout function to enforce execution time limits on futures. - Created Timeout struct for wrapping futures with a deadline. - Added tests for timeout behavior and error mapping.
corex-cache
A unified multi-layer cache abstraction so your app isn't locked to one cache
provider. Combines an in-process L1 cache with a distributed L2 cache
(e.g. Redis/Valkey) behind one simple get/set/invalidate API, plus a
cache-aside / auto-refresh helper.
Features
l1-memory(default) — zero-dependency in-process cache.l1-moka— high-performance Moka-backed L1 with TTL/max-capacity.l2-redis— Redis/Valkey L2 viafred.cache-aside(default) — read-through cache-aside helper.
Usage
use corex_cache::{Cache, MemoryCache, MultiLayerCache, CacheAside};
let cache = MultiLayerCache::new(
MemoryCache::new(), // L1
MemoryCache::new(), // L2 (use RedisCache in production)
);
cache.set("k", b"v".to_vec(), None).await.unwrap();
let v = cache.get("k").await.unwrap();
// Cache-aside: fill misses from a source of truth.
let aside = CacheAside::new(
MemoryCache::new(),
|key| async move { Some(format!("data-for-{key}").into_bytes()) },
);
let _ = aside.get("orders:42").await.unwrap();