v0.12.0
HydraCache 0.12.0 Release Notes
HydraCache 0.12.0 adds reusable database query cache policies and a shorter
repository-style load API.
Highlights
- Added
QueryCachePolicytohydracache-db. - Added
DbCache::cached_with::<T>(policy). - Added
DbQuery::with_policy(policy)andDbQuery::cache_policy(). - Added
DbQuery::collection(name). - Added
DbQuery::load(...)as an alias forfetch_with(...). - Re-exported
QueryCachePolicyfromhydracache-sqlx. - Kept existing
.cached().key().tag().ttl().fetch_with(...),
for_entity(...), and SQLx helper APIs available.
Example
use std::time::Duration;
use hydracache_db::QueryCachePolicy;
let policy = QueryCachePolicy::named("load-user")
.for_cache_entity::<User>(42)
.ttl(Duration::from_secs(60));
let user = queries
.cached_with::<User>(policy)
.load(|| repo.find_user(42))
.await?;Why This Matters
QueryCachePolicy makes the reusable part of a cached database operation
explicit: diagnostic name, key, tags, and TTL. The loader remains caller-owned,
so applications can use SQLx, Diesel, SeaORM, raw clients, or repository
methods without forcing HydraCache to become a database abstraction layer.
Compatibility
This release is additive for public APIs. Existing query descriptors and SQLx
helper calls continue to work.
with_policy(...) replaces the current descriptor policy. It does not merge
old and new tags or TTLs.
Publish Order
Publish in dependency order:
hydracache-corehydracachehydracache-macroshydracache-dbhydracache-sqlx
Wait for crates.io index propagation between dependent crates.