Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Decision Guide

Use this page when you know the shape of the problem but not the HydraCache API to start with.

SituationStart with
Store or load one typed value in-processLocal Cache
Several call sites reuse one value type and namespaceTyped Cache
A normal async function should be cached with less boilerplateCacheable Functions
A DB/repository result needs explicit query-result cachingDatabase Query Caching
A stale value may be acceptable during refreshRefresh and Stale Reads
You need to prove hit/miss/load behaviorDiagnostics and Events
Multiple local caches should observe invalidationsDistributed Invalidation
You need role, membership, generation, or owner vocabularyClient and Member Cluster

API Choices

Use put and get for simple explicit storage.

Use get_or_load when the loader can fail and you want the full local cache API.

Use get_or_insert_with when the loader cannot fail.

Use get_or_load_with_refresh when freshness behavior is a product decision and stale fallback must be visible.

Use cacheable_loader! only after the key, tags, TTL, and loader boundary are already obvious.

Use hydracache-db when cached values are repository or query results, not arbitrary function results.