cache

UDA declaring a per-resource / per-template draft CacheableResult freshness hint for a @resource- or @resourceTemplate-annotated method. The reflection layer plumbs it through to the matching low-level registration so a draft resources/read carries ttlMs / cacheScope. Has no effect on pre-draft protocol versions (the server only emits cache fields when negotiated to draft).

scope_ is "public" (the default) or "private".

@safe
struct cache {}

Members

Variables

scope_
string scope_;

"public" (default) | "private"

ttl
Duration ttl;

how long the result may be cached

Examples

@resource("file:///data", "Data", "application/json")
@cache(5.seconds, "private")
string data() { ... }