Enable Query Caching
Prerequisites
Basic Query Caching
# Cache user by ID for 5 minutes
user = User.cache(5.minutes).find(user_id)
# Cache query results
posts = Post.cache(1.minute)
.where(published: true)
.order(created_at: :desc)
.limit(10)
.allConfigure Default Cache
Cache Stores
Memory Cache
Redis Cache
Cache Keys
Custom Cache Keys
Cache Invalidation
Manual Invalidation
Automatic Invalidation
Conditional Caching
Cache Statistics
Verify Caching
Best Practices
See Also
Last updated
Was this helpful?