Skip to content

v0.12.0

Choose a tag to compare

@javaquasar javaquasar released this 02 Jun 13:17
· 203 commits to main since this release

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 QueryCachePolicy to hydracache-db.
  • Added DbCache::cached_with::<T>(policy).
  • Added DbQuery::with_policy(policy) and DbQuery::cache_policy().
  • Added DbQuery::collection(name).
  • Added DbQuery::load(...) as an alias for fetch_with(...).
  • Re-exported QueryCachePolicy from hydracache-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:

  1. hydracache-core
  2. hydracache
  3. hydracache-macros
  4. hydracache-db
  5. hydracache-sqlx

Wait for crates.io index propagation between dependent crates.