#[cacheable]Expand description
Cache an ordinary async function with explicit local-cache metadata.
The decorated function must be async, return Result<T, E>, and receive the
cache as an explicit argument referenced by cache = .... The generated
wrapper returns hydracache::CacheResult<T> because cache errors can also be
produced outside the user loader.
ยงExample
use hydracache::{cacheable, HydraCache};
#[cacheable(
cache = cache,
key_segments = ["profile", profile_id],
tag_segments = [["profile", profile_id], ["profiles"]],
ttl_secs = 60
)]
async fn load_profile(
cache: &HydraCache,
profile_id: u64,
) -> Result<Profile, LoadError> {
repo_load_profile(profile_id).await
}