@kne/fastify-puppeteer 1.1.3 → 1.1.4
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/libs/services.js +4 -3
- package/package.json +1 -1
package/libs/services.js
CHANGED
|
@@ -13,15 +13,16 @@ module.exports = fp(async (fastify, options) => {
|
|
|
13
13
|
const deferred = createDeferred(maxConcurrent);
|
|
14
14
|
|
|
15
15
|
const memoCache = (cacheName, callback) => async props => {
|
|
16
|
-
const
|
|
17
|
-
|
|
16
|
+
const inputProps = Object.assign({}, props, { cacheName });
|
|
17
|
+
const currentCache = await cache.getCache(inputProps);
|
|
18
|
+
if (currentCache && !inputProps.force) {
|
|
18
19
|
return currentCache;
|
|
19
20
|
}
|
|
20
21
|
const output = await callback(props);
|
|
21
22
|
if (!output.success) {
|
|
22
23
|
throw output.error;
|
|
23
24
|
}
|
|
24
|
-
return await cache.setCache(
|
|
25
|
+
return await cache.setCache(inputProps, output.result);
|
|
25
26
|
};
|
|
26
27
|
|
|
27
28
|
const batchTask = async (list, callback) => {
|