@luvio/environments 0.156.2 → 0.156.4-dev1

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.
@@ -1064,6 +1064,32 @@ function makeDurable(environment, { durableStore, instrumentation, useRevivingSt
1064
1064
  }, revivingStore).finally(() => {
1065
1065
  });
1066
1066
  };
1067
+ const expirePossibleStaleRecords = async function (keys$1, config, refresh) {
1068
+ validateNotDisposed();
1069
+ const metadataKeys = keys$1.map(serializeStructuredKey);
1070
+ const now = Date.now();
1071
+ const entries = await durableStore.getMetadata(metadataKeys, DefaultDurableSegment);
1072
+ if (entries === undefined || keys(entries).length === 0) {
1073
+ return environment.expirePossibleStaleRecords(keys$1);
1074
+ }
1075
+ let metaDataChanged = false;
1076
+ const metadataEntries = metadataKeys.reduce((accu, key) => {
1077
+ const metadataEntry = entries[key];
1078
+ if (metadataEntry.metadata !== undefined) {
1079
+ const metadata = { ...metadataEntry.metadata, expirationTimestamp: now };
1080
+ accu[key] = { metadata };
1081
+ metaDataChanged = true;
1082
+ }
1083
+ return accu;
1084
+ }, {});
1085
+ if (metaDataChanged) {
1086
+ await durableStore.setMetadata(metadataEntries, DefaultDurableSegment);
1087
+ }
1088
+ if (config !== undefined && refresh !== undefined) {
1089
+ return environment.refreshPossibleStaleRecords(config, refresh);
1090
+ }
1091
+ return Promise.resolve();
1092
+ };
1067
1093
  // set the default cache policy of the base environment
1068
1094
  environment.setDefaultCachePolicy({
1069
1095
  type: 'stale-while-revalidate',
@@ -1096,6 +1122,7 @@ function makeDurable(environment, { durableStore, instrumentation, useRevivingSt
1096
1122
  handleErrorResponse: { value: handleErrorResponse },
1097
1123
  getNotifyChangeStoreEntries: { value: getNotifyChangeStoreEntries },
1098
1124
  notifyStoreUpdateAvailable: { value: notifyStoreUpdateAvailable },
1125
+ expirePossibleStaleRecords: { value: expirePossibleStaleRecords },
1099
1126
  });
1100
1127
  }
1101
1128
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luvio/environments",
3
- "version": "0.156.2",
3
+ "version": "0.156.4-dev1",
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.156.2"
30
+ "@luvio/engine": "0.156.4-dev1"
31
31
  },
32
32
  "volta": {
33
33
  "extends": "../../../package.json"