Node Redis Connection pool
Work in progress...
$ npm install redis-pool --save
- Robust connection management
###Security Issues
Create the app:
Install dependencies:
$ npm install
Start the server:
$ npm start
Create client:
const redisPool = require('redis-pool');
const client = redisPool.createClient();
calling the create client without any options, will first create a default connection pool, then it will create a client with default redis options and add it to the pool.
const redisPool = require('redis-pool');
const Redis = require('ioredis');
function clientFactory() {
return new Redis({
sentinels: [{
host: 'localhost',
port: 26379
}],
name: 'mymaster'
});
}
const options = {
poolKey: 'my-pool',
clientKey: 'my-pool',
clientFactory: clientFactory,
redisOptions: {
host: '127.0.0.1',
port: 6379,
options: {}
},
poolOptions: {
min: 1,
max: 2
}
}
redisPool.createClient(options);
const client1 = await redisPool.createClient(options);
const client2 = await redisPool.createClient(options);
To run the test suite, first install the dependencies, then run npm test
:
$ npm install
$ npm test