Skip to main content

HydraCacheEntity

Derive Macro HydraCacheEntity 

Source
#[derive(HydraCacheEntity)]
{
    // Attributes available to this derive:
    #[hydracache]
}
Expand description

Derive CacheEntity metadata for database result-cache helpers.

ยงExample

use hydracache_db::{CacheEntity, HydraCacheEntity};

#[derive(HydraCacheEntity)]
#[hydracache(entity = "user", collection = "users")]
struct User {
    #[hydracache(id)]
    id: i64,
    name: String,
}

assert_eq!(User::cache_key_for(&42), "user:42");

#[hydracache(id = Type)] on the struct remains supported when the id type cannot be inferred from one named field.