Skip to main content

cachekit

Attribute Macro cachekit 

Source
#[cachekit]
Expand description

Cache the result of an async function.

§Attributes

  • client = <ident> (required): Name of the &CacheKit parameter.
  • ttl = <integer> (required): TTL in seconds.
  • namespace = "<string>" (optional): Namespace prefix for the cache key.
  • secure (optional flag): Use encrypted cache via cache.secure().

§Example

ⓘ
#[cachekit(client = cache, ttl = 60)]
async fn get_user(cache: &CacheKit, id: u64) -> Result<User, CachekitError> {
    Ok(User { name: format!("User {id}") })
}