@middy/util 3.3.4 → 3.5.0
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/index.cjs +12 -1
- package/index.js +12 -1
- package/package.json +3 -3
package/index.cjs
CHANGED
|
@@ -141,9 +141,18 @@ const processCache = (options, fetch = ()=>undefined, request)=>{
|
|
|
141
141
|
const value1 = fetch(request);
|
|
142
142
|
const expiry = Date.now() + cacheExpiry;
|
|
143
143
|
if (cacheExpiry) {
|
|
144
|
+
const refresh = cacheExpiry > 0 ? setInterval(()=>{
|
|
145
|
+
const value = fetch(request);
|
|
146
|
+
const expiry = Date.now() + cacheExpiry;
|
|
147
|
+
Object.assign(cache[cacheKey], {
|
|
148
|
+
value,
|
|
149
|
+
expiry
|
|
150
|
+
});
|
|
151
|
+
}, cacheExpiry) : undefined;
|
|
144
152
|
cache[cacheKey] = {
|
|
145
153
|
value: value1,
|
|
146
|
-
expiry
|
|
154
|
+
expiry,
|
|
155
|
+
refresh
|
|
147
156
|
};
|
|
148
157
|
}
|
|
149
158
|
return {
|
|
@@ -157,6 +166,7 @@ const getCache = (key)=>{
|
|
|
157
166
|
};
|
|
158
167
|
const modifyCache = (cacheKey, value)=>{
|
|
159
168
|
if (!cache[cacheKey]) return;
|
|
169
|
+
clearInterval(cache[cacheKey]?.refresh);
|
|
160
170
|
cache[cacheKey] = {
|
|
161
171
|
...cache[cacheKey],
|
|
162
172
|
value,
|
|
@@ -169,6 +179,7 @@ const clearCache = (keys = null)=>{
|
|
|
169
179
|
keys
|
|
170
180
|
];
|
|
171
181
|
for (const cacheKey of keys){
|
|
182
|
+
clearInterval(cache[cacheKey]?.refresh);
|
|
172
183
|
cache[cacheKey] = undefined;
|
|
173
184
|
}
|
|
174
185
|
};
|
package/index.js
CHANGED
|
@@ -114,9 +114,18 @@ export const processCache = (options, fetch = ()=>undefined, request)=>{
|
|
|
114
114
|
const value1 = fetch(request);
|
|
115
115
|
const expiry = Date.now() + cacheExpiry;
|
|
116
116
|
if (cacheExpiry) {
|
|
117
|
+
const refresh = cacheExpiry > 0 ? setInterval(()=>{
|
|
118
|
+
const value = fetch(request);
|
|
119
|
+
const expiry = Date.now() + cacheExpiry;
|
|
120
|
+
Object.assign(cache[cacheKey], {
|
|
121
|
+
value,
|
|
122
|
+
expiry
|
|
123
|
+
});
|
|
124
|
+
}, cacheExpiry) : undefined;
|
|
117
125
|
cache[cacheKey] = {
|
|
118
126
|
value: value1,
|
|
119
|
-
expiry
|
|
127
|
+
expiry,
|
|
128
|
+
refresh
|
|
120
129
|
};
|
|
121
130
|
}
|
|
122
131
|
return {
|
|
@@ -130,6 +139,7 @@ export const getCache = (key)=>{
|
|
|
130
139
|
};
|
|
131
140
|
export const modifyCache = (cacheKey, value)=>{
|
|
132
141
|
if (!cache[cacheKey]) return;
|
|
142
|
+
clearInterval(cache[cacheKey]?.refresh);
|
|
133
143
|
cache[cacheKey] = {
|
|
134
144
|
...cache[cacheKey],
|
|
135
145
|
value,
|
|
@@ -142,6 +152,7 @@ export const clearCache = (keys = null)=>{
|
|
|
142
152
|
keys
|
|
143
153
|
];
|
|
144
154
|
for (const cacheKey of keys){
|
|
155
|
+
clearInterval(cache[cacheKey]?.refresh);
|
|
145
156
|
cache[cacheKey] = undefined;
|
|
146
157
|
}
|
|
147
158
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@middy/util",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"description": "🛵 The stylish Node.js middleware engine for AWS Lambda (util package)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -60,12 +60,12 @@
|
|
|
60
60
|
"url": "https://github.com/middyjs/middy/issues"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@middy/core": "3.
|
|
63
|
+
"@middy/core": "3.5.0",
|
|
64
64
|
"@types/aws-lambda": "^8.10.76",
|
|
65
65
|
"@types/node": "^18.0.0",
|
|
66
66
|
"aws-sdk": "^2.939.0",
|
|
67
67
|
"aws-xray-sdk": "^3.3.3"
|
|
68
68
|
},
|
|
69
69
|
"homepage": "https://middy.js.org",
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "61d1bb405d23702dd8ee83b65d8b98bef7acaeeb"
|
|
71
71
|
}
|