v0.11.0
HydraCache 0.11.0 Release Notes
HydraCache 0.11.0 adds a derive macro for domain entity cache metadata.
Highlights
- Added the publishable
hydracache-macroscrate. - Added
#[derive(HydraCacheEntity)]. - Re-exported
HydraCacheEntityfromhydracache-db. - Re-exported
HydraCacheEntityfromhydracache-sqlx. - Kept manual
CacheEntityimplementations fully supported. - Added compile-pass and compile-fail macro tests with
trybuild. - Updated live documentation examples to use the derive path.
Example
use hydracache_sqlx::{CacheEntity, HydraCacheEntity};
#[derive(HydraCacheEntity)]
#[hydracache(entity = "user", collection = "users", id = i64)]
struct User;
assert_eq!(User::cache_key_for(&42), "user:42");
assert_eq!(User::entity_tag_for(&42), "user:42");
assert_eq!(User::collection_tag(), Some("users".to_owned()));Semantics
entityis required and becomesCacheEntity::ENTITY.idis required and becomesCacheEntity::Id.collectionis optional and becomesCacheEntity::COLLECTION.- Generated keys and tags still use the existing
CacheKeyBuilderescaping
rules through theCacheEntitydefault methods. - The macro does not change
DbCache,DbQuery, SQLx execution, loaders,
single-flight, TTLs, or invalidation semantics.
Backward Compatibility
Manual metadata remains valid:
impl CacheEntity for User {
type Id = i64;
const ENTITY: &'static str = "user";
const COLLECTION: Option<&'static str> = Some("users");
}The full-control descriptor API also remains available:
queries.cached::<User>().key("user:42").tag("user:42")Publish Order
hydracache-macros is now a published crate. Publish in dependency order:
hydracache-corehydracachehydracache-macroshydracache-dbhydracache-sqlx
Wait for crates.io index propagation between dependent crates.
Validation
cargo fmt --all -- --checkcargo check --workspace --all-targets --lockedcargo test --workspace --all-targets --lockedcargo clippy --workspace --all-targets --all-features --locked -- -D warningscargo test --doc --workspace --lockedcargo doc --workspace --no-deps --lockedcargo llvm-cov --workspace --all-targets --locked --summary-only
The SQLx Postgres integration test uses testcontainers. It runs against a real
database when Docker is available and skips successfully when Docker is not
available.
Stable cargo-llvm-cov does not count the exported proc-macro entrypoint as a
normal covered function, even though trybuild executes the macro through
rustc. The macro parser, expansion logic, crate-path resolution, successful
compile cases, and compile-fail diagnostics are covered by unit tests and
trybuild; the remaining function-summary gap is the thin
proc_macro::TokenStream wrapper.