How to use the @hapi/catbox.Client function in @hapi/catbox

To help you get started, we’ve selected a few @hapi/catbox examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TheScienceMuseum / collectionsonline / bin / cache.js View on Github external
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});
github hapijs / hapi / lib / core.js View on Github external
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;
    }
github hapijs / hapi / lib / core.js View on Github external
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;
    }

@hapi/catbox

Multi-strategy object caching service

BSD-3-Clause
Latest version published 1 year ago

Package Health Score

76 / 100
Full package analysis

Popular @hapi/catbox functions