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/stores/ drwxr-xr-x | |
| Viewing file: Select action/file-type: const _ = require('lodash');
const Redis = require('ioredis');
const lru = require('redis-lru');
module.exports = (strapi, opts = {}) => {
const redisOpts = _.get(opts, 'redisConfig', {});
const allowLogs = _.get(opts, 'logs', true);
const prefix = (key) => `strapi-middleware-cache:${key}`;
const unprefix = (key) => key.replace(/^strapi-middleware-cache:/, '')
const client = new Redis(redisOpts);
const cache = lru(client, opts.max);
let reconnected = false;
client.on("ready", () => {
if (allowLogs) {
strapi.log.debug('[Cache] Redis connection established')
}
if (reconnected) {
cache.reset();
}
});
client.on("error", (e) => {
strapi.log.error(`[Cache] Redis connection failed`)
strapi.log.error(e);
});
client.on("reconnecting", (e) => {
reconnected = true;
});
return {
get(key) {
return cache.get(prefix(key));
},
set(key, val, maxAge) {
return cache.set(prefix(key), val, maxAge);
},
peek(key) {
return cache.peek(prefix(key));
},
del(key) {
return cache.del(prefix(key));
},
async keys() {
const keys = await cache.keys();
return keys.map(unprefix);
},
reset() {
return cache.reset();
},
get ready() {
return client.status === 'ready';
}
};
} |
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0364 ]-- |