[−][src]Attribute Macro cached_proc_macro::cached
#[cached]
Attributes
- Cache Name: Use
name = "CACHE_NAME"
to specify the name for the generated cache. - Cache Type: The default cache type is
UnboundCache
. You specify which of the built-in cache types to use withunbound
,size = cache_size
, ortime = lifetime_in_seconds
- Cache Create: You can specify the cache creation with
create = "{ CacheType::new() }"
. - Custom Cache Type: You can use
type = "CacheType"
to specify the type of cache to use. This requires create to also be set. - Cache Key: Use
key = "KeyType"
to specify what type to use for the cache key. This requires convert to also be set. - Cache Key Convert: Use
convert = "{ convert_inputs_to_key }"
. This requires either key or type to also be set. - Caching Result/Option: If your function returns a
Result
orOption
you may want to useresult
oroption
to only cache when the output isOk
orSome
Note
The type
, create
, key
, and convert
attributes must be in a String
This is because darling, which is used for parsing the attributes, does not support parsing attributes into Type
or Block
.