Set Up Memory Cache
Basic Setup
Azu.configure do |config|
config.cache = Azu::Cache::MemoryStore.new
endUsing the Cache
Store and Retrieve Values
# Store a value
Azu.cache.set("user:1", user.to_json)
# Retrieve a value
json = Azu.cache.get("user:1")
if json
user = User.from_json(json)
end
# With expiration (TTL)
Azu.cache.set("session:abc123", session_data, expires_in: 30.minutes)Fetch Pattern
Delete Keys
Check Existence
Clear All
Caching in Endpoints
Cache Configuration Options
Namespacing Keys
Cache Invalidation
Thread Safety
Cache Statistics
When to Use Memory Cache
See Also
Last updated
Was this helpful?
