Skip to main content

Module cache

Module cache 

Source
Expand description

§Rullst Cache System (rullst::cache)

Provides a unified caching API with pluggable drivers.

§Drivers

  • In-Memory (default): DashMap-based concurrent store with TTL support. Zero config.
  • Redis (optional): Requires the cache-redis feature flag.

§Quick Start

use rullst::cache::Cache;

let cache = Cache::memory();

// Store a value with 60-second TTL
cache.put("user:42:name", "Alice", Some(60)).await?;

// Retrieve it
let name = cache.get("user:42:name").await?; // Some("Alice")

// Cache-aside pattern: fetch from cache or compute + store
let value = cache.remember("expensive_key", 300, || async {
    Ok("computed_value".to_string())
}).await?;

Structs§

Cache
The main cache facade for storing and retrieving cached values.
MemoryDriver
In-memory cache driver using DashMap for lock-free concurrent access.

Enums§

CacheError
Errors that can occur during cache operations.

Traits§

CacheDriver
Abstraction over cache storage backends.