ferro-cache
Caching with tags for the Ferro framework.
Features
- Multiple backends (Redis, in-memory)
- Cache tags for bulk invalidation
- Remember pattern for lazy caching
- TTL (time-to-live) support
Usage
use ;
use Duration;
// Create in-memory cache
let cache = memory;
// Store a value
cache.put.await?;
// Get a value
let user: = cache.get.await?;
// Delete a value
cache.forget.await?;
Remember Pattern
Get from cache or compute and store:
let users = cache.remember.await?;
Cache Tags
Tags allow bulk invalidation of related entries:
// Store with tags
cache.tags
.put
.await?;
cache.tags
.put
.await?;
// Flush all entries tagged with "users"
cache.tags.flush.await?;
// Both user:1 and user:2 are now invalidated
Redis Backend
Enable the redis-backend feature:
[]
= { = "0.1", = ["redis-backend"] }
let cache = redis.await?;
License
MIT