Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const Catbox = require('@hapi/catbox');
const CatboxRedis = require('@hapi/catbox-redis');
var elasticacheHost = '127.0.0.1';
var elasticachePort = '6379';
if (process.env.ELASTICACHE_EP) {
var config = process.env.ELASTICACHE_EP.split(':');
elasticacheHost = config[0];
elasticachePort = config[1];
}
module.exports = new Catbox.Client(CatboxRedis, {host: elasticacheHost, port: elasticachePort});
const name = config.name || '_default';
Hoek.assert(!this.caches.has(name), 'Cannot configure the same cache more than once: ', name === '_default' ? 'default cache' : name);
let client = null;
if (config.provider) {
let provider = config.provider;
if (typeof provider === 'function') {
provider = { constructor: provider };
}
client = new Catbox.Client(provider.constructor, provider.options || { partition: 'hapi-cache' });
}
else {
client = new Catbox.Client(config.engine);
}
this.caches.set(name, { client, segments: {}, shared: config.shared || false });
added.push(client);
}
return added;
}
if (typeof config === 'function') {
config = { provider: { constructor: config } };
}
const name = config.name || '_default';
Hoek.assert(!this.caches.has(name), 'Cannot configure the same cache more than once: ', name === '_default' ? 'default cache' : name);
let client = null;
if (config.provider) {
let provider = config.provider;
if (typeof provider === 'function') {
provider = { constructor: provider };
}
client = new Catbox.Client(provider.constructor, provider.options || { partition: 'hapi-cache' });
}
else {
client = new Catbox.Client(config.engine);
}
this.caches.set(name, { client, segments: {}, shared: config.shared || false });
added.push(client);
}
return added;
}