Caching
Ryx includes an in-memory query cache.
Setupโ
use ryx_rs::cache::{MemoryCache, configure_cache};
configure_cache(MemoryCache::new(1000));
Creates an LRU cache with 1000 entry capacity.
Cached Queriesโ
let posts: Vec<Post> = Post::objects()
.filter("active", true)
.cache(60, Some("active_posts")) // TTL: 60 seconds, named key
.all().await?;
The cache() method takes:
| Parameter | Description |
|---|---|
| TTL (seconds) | Time-to-live before the cache entry expires |
| Key (optional) | Named key for manual invalidation |
Next Stepsโ
- Filtering โ Query reference