@@ -11,6 +11,14 @@ export type Options = {
11
11
id ?: Node [ "id" ] ;
12
12
/** When true the server will omit this node's output. Default: false */
13
13
hide ?: boolean ;
14
+ /** Number of seconds to cache an output for this node's unique inputs. Default: null */
15
+ cache_age ?: number ;
16
+ /** Applies if cache_age > 0. Optionally specify a subset of keys to use when computing a cache key.
17
+ * Default: all node arguments
18
+ */
19
+ cache_keys ?: string [ ] ;
20
+ /** Max number of times to retry this node if it fails. Default: null means no retries */
21
+ max_retries ?: number ;
14
22
} ;
15
23
16
24
export abstract class Node {
@@ -22,6 +30,14 @@ export abstract class Node {
22
30
args : Object ;
23
31
/** When true the server will omit this node's output. Default: false */
24
32
hide : boolean ;
33
+ /** Number of seconds to cache an output for this node's unique inputs. Default: null */
34
+ cache_age ?: number ;
35
+ /** Applies if cache_age > 0. Optionally specify a subset of keys to use when computing a cache key.
36
+ * Default: all node arguments
37
+ */
38
+ cache_keys ?: string [ ] ;
39
+ /** Max number of times to retry this node if it fails. Default: null means no retries */
40
+ max_retries ?: number ;
25
41
26
42
/** TODO this field stores the last response, but it's just temporary until the internals are refactored */
27
43
protected _response : SubstrateResponse | undefined ;
@@ -31,6 +47,9 @@ export abstract class Node {
31
47
this . args = args ;
32
48
this . id = opts ?. id || generator ( this . node ) ;
33
49
this . hide = opts ?. hide || false ;
50
+ this . cache_age = opts ?. cache_age ;
51
+ this . cache_keys = opts ?. cache_keys ;
52
+ this . max_retries = opts ?. max_retries ;
34
53
}
35
54
36
55
/**
@@ -103,6 +122,9 @@ export abstract class Node {
103
122
node : this . node ,
104
123
args : withPlaceholders ( this . args ) ,
105
124
_should_output_globally : ! this . hide ,
125
+ ...( this . cache_age && { _cache_age : this . cache_age } ) ,
126
+ ...( this . cache_keys && { _cache_keys : this . cache_keys } ) ,
127
+ ...( this . max_retries && { _max_retries : this . max_retries } ) ,
106
128
} ;
107
129
}
108
130
0 commit comments