What problem does it solve?
ix-cache solves the problem of needing an efficient in-memory key-value store for applications that require caching, TTL-based expiry, LRU eviction, pub/sub messaging, or a lightweight Redis-compatible RESP server.
Core Features & Use Cases
- Key-Value Store: Offers concurrent sharded HashMap with
set, get, delete, keys operations.
- TTL Management: Time-to-live expiry for keys to maintain cache freshness.
- LRU Eviction: Implements LRU eviction when the cache reaches its capacity.
- Pub/Sub Messaging: Provides in-process publish/subscribe channels for real-time updates.
- RESP Server: Offers a Redis-compatible protocol server for integrating with other Redis clients.
- Persistence: Allows snapshotting to disk for data preservation and can restore from these snapshots on startup.
Quick Start
To get started, create an instance of the Cache and set a key with a TTL, then retrieve it:
use ix_cache::{Cache, CacheConfig};
let cache = Cache::new(CacheConfig::default());
cache.set("key", &json!("value"), Some(std::time::Duration::from_secs(10)));
if let Some(value) = cache.get("key") {
println!("Value retrieved: {:?}", value);
}