@agoric/cache 0.3.3-dev-d6fae11.0.d6fae11 → 0.3.3-dev-64cee5a.0.64cee5a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -7
- package/src/cache.js +2 -1
- package/src/state.js +5 -1
- package/src/store.js +12 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/cache",
|
|
3
|
-
"version": "0.3.3-dev-
|
|
3
|
+
"version": "0.3.3-dev-64cee5a.0.64cee5a",
|
|
4
4
|
"description": "Agoric's simple cache interface",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/main.js",
|
|
@@ -19,15 +19,15 @@
|
|
|
19
19
|
"author": "Agoric",
|
|
20
20
|
"license": "Apache-2.0",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@agoric/internal": "0.3.3-dev-
|
|
23
|
-
"@agoric/notifier": "0.6.3-dev-
|
|
24
|
-
"@agoric/store": "0.9.3-dev-
|
|
25
|
-
"@agoric/vat-data": "0.5.3-dev-
|
|
22
|
+
"@agoric/internal": "0.3.3-dev-64cee5a.0.64cee5a",
|
|
23
|
+
"@agoric/notifier": "0.6.3-dev-64cee5a.0.64cee5a",
|
|
24
|
+
"@agoric/store": "0.9.3-dev-64cee5a.0.64cee5a",
|
|
25
|
+
"@agoric/vat-data": "0.5.3-dev-64cee5a.0.64cee5a",
|
|
26
26
|
"@endo/far": "^1.1.14",
|
|
27
27
|
"@endo/marshal": "^1.8.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@agoric/zoe": "0.26.3-dev-
|
|
30
|
+
"@agoric/zoe": "0.26.3-dev-64cee5a.0.64cee5a",
|
|
31
31
|
"ava": "^5.3.0",
|
|
32
32
|
"c8": "^10.1.3"
|
|
33
33
|
},
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"typeCoverage": {
|
|
50
50
|
"atLeast": 94.13
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "64cee5ae5d1a3488a30ce042d6f3f561ac2a6e82"
|
|
53
53
|
}
|
package/src/cache.js
CHANGED
|
@@ -7,6 +7,7 @@ import { makeScalarStoreCoordinator } from './store.js';
|
|
|
7
7
|
/**
|
|
8
8
|
* @import {Passable, RemotableObject} from '@endo/pass-style';
|
|
9
9
|
* @import {Key, Pattern} from '@endo/patterns';
|
|
10
|
+
* @import {Coordinator} from './types.js';
|
|
10
11
|
*/
|
|
11
12
|
|
|
12
13
|
/**
|
|
@@ -17,7 +18,7 @@ import { makeScalarStoreCoordinator } from './store.js';
|
|
|
17
18
|
*/
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
|
-
* @param {ERef<
|
|
21
|
+
* @param {ERef<Coordinator>} [coordinator]
|
|
21
22
|
*/
|
|
22
23
|
export const makeCache = (coordinator = makeScalarStoreCoordinator()) => {
|
|
23
24
|
/**
|
package/src/state.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
// @jessie-check
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* @import {State} from './state.js';
|
|
5
|
+
*/
|
|
6
|
+
|
|
3
7
|
/**
|
|
4
8
|
* @typedef {object} State
|
|
5
9
|
* @property {bigint} generation
|
|
@@ -30,7 +34,7 @@ export const makeState = (value, priorState = GROUND_STATE) =>
|
|
|
30
34
|
/**
|
|
31
35
|
* Wrap a state store to have a default value using the GROUND_STATE
|
|
32
36
|
*
|
|
33
|
-
* @param {MapStore<string,
|
|
37
|
+
* @param {MapStore<string, State>} stateStore
|
|
34
38
|
*/
|
|
35
39
|
export const withGroundState = stateStore => ({
|
|
36
40
|
...stateStore,
|
package/src/store.js
CHANGED
|
@@ -10,6 +10,8 @@ import { withGroundState, makeState } from './state.js';
|
|
|
10
10
|
* @import {EMarshaller} from '@agoric/internal/src/marshal/wrap-marshaller.js';
|
|
11
11
|
* @import {Passable, RemotableObject} from '@endo/pass-style';
|
|
12
12
|
* @import {Key, Pattern} from '@endo/patterns';
|
|
13
|
+
* @import {State} from './state.js';
|
|
14
|
+
* @import {Coordinator} from './types.js';
|
|
13
15
|
*/
|
|
14
16
|
|
|
15
17
|
/**
|
|
@@ -47,9 +49,9 @@ const makeKeyToString = (sanitize = obj => obj) => {
|
|
|
47
49
|
* @param {(obj: Passable) => Passable} sanitize Process keys and values with
|
|
48
50
|
* this function before storing them
|
|
49
51
|
* @param {{
|
|
50
|
-
* get(key: string):
|
|
51
|
-
* set(key: string, value:
|
|
52
|
-
* init(key: string, value:
|
|
52
|
+
* get(key: string): State;
|
|
53
|
+
* set(key: string, value: State): void;
|
|
54
|
+
* init(key: string, value: State): void;
|
|
53
55
|
* }} stateStore
|
|
54
56
|
* @returns {Promise<Passable>} the value of the updated state
|
|
55
57
|
*/
|
|
@@ -63,8 +65,8 @@ const applyCacheTransaction = async (
|
|
|
63
65
|
/**
|
|
64
66
|
* Retrieve a potential updated state from the transaction.
|
|
65
67
|
*
|
|
66
|
-
* @param {
|
|
67
|
-
* @returns {Promise<
|
|
68
|
+
* @param {State} basisState
|
|
69
|
+
* @returns {Promise<State | null>} the updated state, or null if no longer applicable
|
|
68
70
|
*/
|
|
69
71
|
const getUpdatedState = async basisState => {
|
|
70
72
|
const { value } = basisState;
|
|
@@ -113,7 +115,7 @@ const applyCacheTransaction = async (
|
|
|
113
115
|
};
|
|
114
116
|
|
|
115
117
|
/**
|
|
116
|
-
* @param {MapStore<string,
|
|
118
|
+
* @param {MapStore<string, State>} stateStore
|
|
117
119
|
* @param {ERemote<EMarshaller>} marshaller
|
|
118
120
|
* @returns {Promise<string>}
|
|
119
121
|
*/
|
|
@@ -132,7 +134,7 @@ const stringifyStateStore = async (stateStore, marshaller) => {
|
|
|
132
134
|
* Make a cache coordinator backed by a MapStore. This coordinator doesn't
|
|
133
135
|
* currently enforce any cache eviction, but that would be a useful feature.
|
|
134
136
|
*
|
|
135
|
-
* @param {MapStore<string,
|
|
137
|
+
* @param {MapStore<string, State>} [stateStore]
|
|
136
138
|
* @param {(obj: Passable) => Passable} [sanitize] Process keys and values with
|
|
137
139
|
* this function before storing them. Defaults to deeplyFulfilled.
|
|
138
140
|
*/
|
|
@@ -144,7 +146,7 @@ export const makeScalarStoreCoordinator = (
|
|
|
144
146
|
|
|
145
147
|
const defaultStateStore = withGroundState(stateStore);
|
|
146
148
|
|
|
147
|
-
/** @type {
|
|
149
|
+
/** @type {Coordinator} */
|
|
148
150
|
const coord = Far('store cache coordinator', {
|
|
149
151
|
getRecentValue: async key => {
|
|
150
152
|
const keyStr = await serializePassable(key);
|
|
@@ -177,7 +179,7 @@ export const makeScalarStoreCoordinator = (
|
|
|
177
179
|
/**
|
|
178
180
|
* Don't write any marshalled value that's older than what's already pushed
|
|
179
181
|
*
|
|
180
|
-
* @param {MapStore<string,
|
|
182
|
+
* @param {MapStore<string, State>} stateStore
|
|
181
183
|
* @param {ERemote<EMarshaller>} marshaller
|
|
182
184
|
* @param {ERemote<StorageNode>} storageNode
|
|
183
185
|
* @returns {<T>(storedValue: T) => Promise<T>}
|
|
@@ -224,7 +226,7 @@ export const makeChainStorageCoordinator = (storageNode, marshaller) => {
|
|
|
224
226
|
storageNode,
|
|
225
227
|
);
|
|
226
228
|
|
|
227
|
-
/** @type {
|
|
229
|
+
/** @type {Coordinator} */
|
|
228
230
|
const coord = Far('store cache coordinator', {
|
|
229
231
|
getRecentValue: async key => {
|
|
230
232
|
const keyStr = await serializePassable(key);
|