Skip to main content

Crate ferro_cache

Crate ferro_cache 

Source
Expand description

§Ferro Cache

Caching with tags for the Ferro framework.

Provides a unified caching API with support for:

  • Multiple backends (Redis, in-memory)
  • Cache tags for bulk invalidation
  • Remember pattern for lazy caching
  • TTL (time-to-live) support

§Example

use ferro_cache::{Cache, CacheConfig};
use std::time::Duration;

// Create cache
let cache = Cache::memory();

// Store a value
cache.put("user:1", &user, Duration::from_secs(3600)).await?;

// Get a value
let user: User = cache.get("user:1").await?;

// Remember pattern - get from cache or compute
let users = cache.remember("users:active", Duration::from_secs(3600), || async {
    User::where_active().all().await
}).await?;

§Cache Tags

Tags allow bulk invalidation of related cache entries:

// Store with tags
cache.tags(&["users", "admins"])
    .put("user:1", &admin, Duration::from_secs(3600))
    .await?;

// Flush all entries with a tag
cache.tags(&["users"]).flush().await?;

Re-exports§

pub use serde;

Structs§

Cache
Main cache facade.
CacheConfig
Cache store configuration.
MemoryStore
In-memory cache store.
TaggedCache
A cache instance with tags for grouped operations.

Enums§

Error
Cache error types.

Traits§

CacheStore
Cache store trait.

Attribute Macros§

async_trait
Re-export for convenience.