swapez-cache-repo
v1.0.5
Published
Vnng Cache Repository Module
Downloads
3
Readme
VNNG Repository
Cache Repository for Swap-Ez's services
Installation
npm install swapez-cache-repo --save
or
yarn add cache-repo
Usage
const cacheRepo = require('swapez-cache-repo');
const cacheStoreSettings = () => ({
host: process.env.REDIS_HOST || 'localhost',
port: process.env.REDIS_PORT || 'port',
password: process.env.REDIS_PWD || 'password'
});
const connect = (cacheStoreSettings) => new Promise(function (resolve, reject) {
const redisClient = new redis.createClient(cacheStoreSettings());
redisClient.on('ready', () => {
debug('ready');
resolve(redisClient);
});
redisClient.on('error', (err) => {
debug('error');
reject(err);
});
});
connect(cacheStoreSettings).then((redisClient) => {
const container = createContainer();
container.register(CACHE_STORE, asValue(redisClient));
return cacheRepo.connect(container);
}).then((container) => {
const { checkExistsAnonymous } = container.cradle.cacheRepo;
});