7
7
8
8
### Changelog
9
9
10
+ - 0.2.0
11
+
12
+ - Add Time Units
13
+ - Clarify Inflight TTL and Grace Interval
14
+
10
15
- 0.1.0
11
16
- Initial record
12
17
- [ Thread Safe Cache] ( ../changes/2023-06-19_thread_safe_cache/change.md )
@@ -18,7 +23,8 @@ is a built-in implementation of the [CMC interface](cryptographic-materials-cach
18
23
provided by the AWS Encryption SDK.
19
24
20
25
It provides thread safe access to a [ Local CMC] ( local-cryptographic-materials-cache.md ) ,
21
- and prevents excessive parallel requests to the underlying cryptographic materials provider.
26
+ prevents excessive parallel requests to the underlying cryptographic materials provider,
27
+ and prevents redundant requests to the underlying cryptographic materials provider for the same key.
22
28
23
29
## Definitions
24
30
@@ -41,6 +47,10 @@ Initialization MUST also provide
41
47
- [ Inflight TTL] ( #inflight-ttl )
42
48
- [ sleepMilli] ( #sleepmilli )
43
49
50
+ Initialization MUST optionally accept the following values:
51
+
52
+ - [ timeUnits] (#time units)
53
+
44
54
The implementation MUST instantiate a [ Local CMC] ( local-cryptographic-materials-cache.md )
45
55
to do the actual caching.
46
56
@@ -53,24 +63,41 @@ attempts will be made to refresh the cache.
53
63
54
64
This should be significantly less than the TTL for any item put into the cache.
55
65
66
+ The Grace Period should be at least a few times larger than the Grace Interval,
67
+ so that if something goes wrong with the first request, a second or third request will be made.
68
+
56
69
### Grace Interval
57
70
58
71
A number of seconds (at least 1, default 1).
59
72
60
- While within the [ grace period] ( #grace-period ) ,
61
- attempts to refresh the cache are made no more often than once per interval.
73
+ An entry that has been in flight for this long is no longer considered in flight.
74
+
75
+ While within the [ grace period] ( #grace-period ) , after this period another request is made.
76
+
77
+ While doing the initial fetch for a key, after this period another request is made.
78
+
79
+ The Grace Interval should be larger than the longest time expected for a request to the underlying cryptographic materials provider.
62
80
63
81
### FanOut
64
82
65
83
A number (at least 1, default 20).
66
84
67
85
The maximum number of individual keys for which lookups can be in flight.
68
86
87
+ Other requests are blocked until the number of unique keys with outstanding requests drops below this number,
88
+ or until the amount of time that request has been outstanding exceeds the [ Inflight TTL] ( #inflight-ttl ) .
89
+
69
90
### Inflight TTL
70
91
71
92
A number (at least 1, default 20).
72
93
73
- An entry that has been in flight for this long is no longer considered in flight.
94
+ A request that has been in flight for this long returns an "InFlightTTL exceeded" error.
95
+
96
+ If a thread has been sleeping because other threads are allegedly working on the same key,
97
+ it will give up and return an error after this amount of time.
98
+
99
+ The Inflight TTL should be at least a few times larger than the Grace Interval,
100
+ so that if something goes wrong with the first request, a second or third request will be made.
74
101
75
102
### SleepMilli
76
103
@@ -80,6 +107,20 @@ If the implementation must block, and no more intelligent signaling is used,
80
107
then the implementation should sleep for this many milliseconds before
81
108
reexamining the state of the cache.
82
109
110
+ SleepMilli MUST NOT be affected by [ timeUnits] (#time units)
111
+
112
+ ### Time Units
113
+
114
+ Time Units MUST be either ` Seconds ` or ` Milliseconds ` and applies to
115
+
116
+ - [ Grace Period] ( #grace-period )
117
+ - [ Grace Interval] ( #grace-interval )
118
+ - [ Inflight TTL] ( #inflight-ttl )
119
+
120
+ If unset, or set to ` Seconds ` , the above values MUST be interpreted as seconds.
121
+
122
+ If set to ` Milliseconds ` , the above values MUST be interpreted as milliseconds.
123
+
83
124
## Consistency
84
125
85
126
The settings need to be consistent.
@@ -171,6 +212,9 @@ one thread receives NoSuchEntry, while others are blocked until an entry appears
171
212
- If the key _ is not_ inflight
172
213
GetCacheEntry MUST return NoSuchEntry and mark that key as inflight at the current time.
173
214
215
+ - If the key _ is_ inflight
216
+ and the time spent so far exceeds the [ Inflight TTL] ( #inflight-ttl ) , the operation MUST fail.
217
+
174
218
- If the key _ is_ inflight
175
219
and the current time _ is_ [ within the grace interval] ( #within-grace-interval )
176
220
GetCacheEntry MUST block until a [ FanOut] ( #fanout ) slot is available, or the key appears in the cache.
0 commit comments