@luvio/environments 0.154.17-dev2 → 0.154.17-dev3
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/dist/environments.js +27 -0
- package/package.json +2 -2
package/dist/environments.js
CHANGED
|
@@ -1055,6 +1055,32 @@ function makeDurable(environment, { durableStore, instrumentation, useRevivingSt
|
|
|
1055
1055
|
}, revivingStore).finally(() => {
|
|
1056
1056
|
});
|
|
1057
1057
|
};
|
|
1058
|
+
const expirePossibleStaleRecords = async function (keys$1, config, refresh) {
|
|
1059
|
+
validateNotDisposed();
|
|
1060
|
+
const metadataKeys = keys$1.map(serializeStructuredKey);
|
|
1061
|
+
const now = Date.now();
|
|
1062
|
+
const entries = await durableStore.getMetadata(metadataKeys, DefaultDurableSegment);
|
|
1063
|
+
if (entries === undefined || keys(entries).length === 0) {
|
|
1064
|
+
return environment.expirePossibleStaleRecords(keys$1);
|
|
1065
|
+
}
|
|
1066
|
+
let metaDataChanged = false;
|
|
1067
|
+
const metadataEntries = metadataKeys.reduce((accu, key) => {
|
|
1068
|
+
const metadataEntry = entries[key];
|
|
1069
|
+
if (metadataEntry.metadata !== undefined) {
|
|
1070
|
+
const metadata = { ...metadataEntry.metadata, expirationTimestamp: now };
|
|
1071
|
+
accu[key] = { metadata };
|
|
1072
|
+
metaDataChanged = true;
|
|
1073
|
+
}
|
|
1074
|
+
return accu;
|
|
1075
|
+
}, {});
|
|
1076
|
+
if (metaDataChanged) {
|
|
1077
|
+
await durableStore.setMetadata(metadataEntries, DefaultDurableSegment);
|
|
1078
|
+
}
|
|
1079
|
+
if (config !== undefined && refresh !== undefined) {
|
|
1080
|
+
return environment.refreshPossibleStaleRecords(config, refresh);
|
|
1081
|
+
}
|
|
1082
|
+
return Promise.resolve();
|
|
1083
|
+
};
|
|
1058
1084
|
// set the default cache policy of the base environment
|
|
1059
1085
|
environment.setDefaultCachePolicy({
|
|
1060
1086
|
type: 'stale-while-revalidate',
|
|
@@ -1087,6 +1113,7 @@ function makeDurable(environment, { durableStore, instrumentation, useRevivingSt
|
|
|
1087
1113
|
handleErrorResponse: { value: handleErrorResponse },
|
|
1088
1114
|
getNotifyChangeStoreEntries: { value: getNotifyChangeStoreEntries },
|
|
1089
1115
|
notifyStoreUpdateAvailable: { value: notifyStoreUpdateAvailable },
|
|
1116
|
+
expirePossibleStaleRecords: { value: expirePossibleStaleRecords },
|
|
1090
1117
|
});
|
|
1091
1118
|
}
|
|
1092
1119
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luvio/environments",
|
|
3
|
-
"version": "0.154.17-
|
|
3
|
+
"version": "0.154.17-dev3",
|
|
4
4
|
"description": "Luvio Environments",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"watch": "yarn build --watch"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@luvio/engine": "0.154.17-
|
|
30
|
+
"@luvio/engine": "0.154.17-dev3"
|
|
31
31
|
},
|
|
32
32
|
"volta": {
|
|
33
33
|
"extends": "../../../package.json"
|