#[once]
Expand description
Define a memoized function using a cache store that implements cached::Cached
(and
cached::CachedAsync
for async functions). Function arguments are not used to identify
a cached value, only one value is cached unless a time
expiry is specified.
ยงAttributes
name
: (optional, string) specify the name for the generated cache, defaults to the function name uppercase.time
: (optional, u64) specify a cache TTL in seconds, implies the cache type is aTimedCached
orTimedSizedCache
.sync_writes
: (optional, bool) specify whether to synchronize the execution of writing of uncached values.result
: (optional, bool) If your function returns aResult
, only cacheOk
values returned by the function.option
: (optional, bool) If your function returns anOption
, only cacheSome
values returned by the function.with_cached_flag
: (optional, bool) If your function returns acached::Return
orResult<cached::Return, E>
, thecached::Return.was_cached
flag will be updated when a cached value is returned.