1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
use crateMacroArgs;
use ;
use TokenStream;
use ;
/// Define a memoized function
///
/// By default, it keeps the cache in memory, unless you define `disk` or `redis`.
///
/// In the attribute list below, `size` and `sync_writes` are possible just if it's a memory cache.
///
/// # Attributes
/// - `name`: (optional, string) Specify the name for the generated cache, defaults to the function name uppercase.
/// - `size`: (optional, string) Specify to keep the amount of entries in the cache.
/// - `ttl`: (optional, string) Specify a cache TTL in seconds.
/// - `sync_writes`: (optional) Specify whether to synchronize the execution of writing uncached values.
/// - `key`: (optional, string) Specify a specific key to use. You need to define the following attributes for a custom `key`, e.g., `key(ty = "String", expr = r#"{ format!("{}:{}", arg1, arg2) }"#)`.
/// - `ty`: (string) Specify type of the key. E.g, `ty = "String"`
/// - `expr`: (string expr) Specify an expression used to generate a cache key.
/// E.g., `expr = r#"{ format!("{}:{}", arg1, arg2) }"#`.
/// - `result`: (optional) If your function returns a `Result`, only cache `Ok` values returned by the function.
/// - `option`: (optional) If your function returns an `Option`, only cache `Some` values returned by the function.
/// - `in_impl`: (optional) Set it if your function is defined in an `impl` block or not.
/// - `redis`: (optional) Store cached values in Redis.
/// - `prefix_block`: (optional, string expr) specify an expression used to create the string used as a
/// prefix for all cache keys of this function, e.g. `prefix_block = r#"{ "my_prefix" }"#`.
/// When not specified, the cache prefix will be constructed from the name of the function. This
/// could result in unexpected conflicts between kash-functions of the same name, so it's
/// recommended that you specify a prefix you're sure will be unique.
/// - `disk`: (optional) Store cached values on disk.
/// - `dir`: (optional, string) Specify directory of `disk` cache
/// - `sync_to_disk_on_cache_change`: (optional) Specify whether to synchronize the cache to disk each
/// time the cache changes.
/// - `connection_config`: (optional, string expr) Specify an expression which returns a `sled::Config`
/// to give more control over the connection to the `disk` cache, i.e., useful for controlling the rate at which the cache syncs to disk.
/// See the docs of `kash::stores::DiskCacheBuilder::connection_config` for more info.
///