Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/wincloud_gateway/node_modules/strapi-middleware-cache/lib/cache/ drwxr-xr-x | |
| Viewing file: Select action/file-type: const _ = require('lodash');
const rejectAfterTimeout = (ms) => new Promise((_, reject) => setTimeout(reject, ms));
const serialize = (data) => {
return JSON.stringify({ data });
}
const deserialize = (str) => {
if (!str) {
return null;
}
return JSON.parse(str).data;
}
module.exports = (strapi, type = 'mem', opts = {}) => {
opts.max = opts.max || 500;
opts.maxAge = opts.maxAge || 60 * 60 * 1000;
const allowLogs = _.get(opts, 'logs', true);
const { cacheTimeout = 500, ...storeOpts } = opts;
const store = require(`./stores/${type}`)(strapi, storeOpts);
return _.mapValues({
async get(key) {
return deserialize(await store.get(key));
},
async set(key, val, maxAge = opts.maxAge) {
return await store.set(key, serialize(val), maxAge);
},
async peek(key) {
return deserialize(await store.peek(key));
},
async del(key) {
await store.del(key);
},
async keys() {
return await store.keys();
},
async reset() {
return await store.reset();
}
}, (fn) => async (...args) => {
try {
if (!store.ready) {
if (allowLogs) {
strapi.log.warn('[Cache] The store is not ready');
}
return null;
}
return await Promise.race([
fn(...args),
rejectAfterTimeout(cacheTimeout)
]);
} catch(e) {
if (e && allowLogs) {
strapi.log.warn('[Cache] There was an error with the store', e);
} else if (allowLogs) {
strapi.log.warn('[Cache] The cache request timed out');
}
return null;
}
});
};
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0263 ]-- |