index.js
function RedisPool(opts) {

    if (!(this instanceof RedisPool)) {
        return new RedisPool(opts);
    }

    EventEmitter.call(this);

    opts = opts || {};
    var defaults = {
        host: '127.0.0.1',
        port: '6379',
        max: 50,
        idleTimeoutMillis: 10000,
        reapIntervalMillis: 1000,
        noReadyCheck: false,
        returnToHead: false,
        unwatchOnRelease: true,
        name: 'default',
        log: false,
        slowPool: {
            log: false,
            elapsedThreshold: 25
        },
        emitter: {
            statusInterval: 60000
        },
        commands: []
    };

    this.options = _.defaults(opts, defaults);
    this.pools = {};
    this.elapsedThreshold = this.options.slowPool.elapsedThreshold;

    // add custom Redis commands
    if (this.options.commands && this.options.commands.length) {
        this.options.commands.forEach(function(newCommand) {
            redis.add_command(newCommand);
        });
    }

    var self = this;
    setInterval(function() {
        Object.keys(self.pools).forEach(function(poolKey) {
            var pool = self.pools[poolKey];
            self.emit('status', {
                name: self.options.name,
                db: poolKey,
                count: pool.getPoolSize(),
                unused: pool.availableObjectsCount(),
                waiting:  pool.waitingClientsCount()
            });
        });
    }, this.options.emitter.statusInterval);
}
function RedisPool(opts) {

    if (!(this instanceof RedisPool)) {
        return new RedisPool(opts);
    }

    EventEmitter.call(this);

    opts = opts || {};
    var defaults = {
        host: '127.0.0.1',
        port: '6379',
        max: 50,
        idleTimeoutMillis: 10000,
        reapIntervalMillis: 1000,
        noReadyCheck: false,
        returnToHead: false,
        unwatchOnRelease: true,
        name: 'default',
        log: false,
        slowPool: {
            log: false,
            elapsedThreshold: 25
        },
        emitter: {
            statusInterval: 60000
        },
        commands: []
    };

    this.options = _.defaults(opts, defaults);
    this.pools = {};
    this.elapsedThreshold = this.options.slowPool.elapsedThreshold;

    // add custom Redis commands
    if (this.options.commands && this.options.commands.length) {
        this.options.commands.forEach(function(newCommand) {
            redis.add_command(newCommand);
        });
    }

    var self = this;
    setInterval(function() {
        Object.keys(self.pools).forEach(function(poolKey) {
            var pool = self.pools[poolKey];
            self.emit('status', {
                name: self.options.name,
                db: poolKey,
                count: pool.getPoolSize(),
                unused: pool.availableObjectsCount(),
                waiting:  pool.waitingClientsCount()
            });
        });
    }, this.options.emitter.statusInterval);
}
function RedisPool ( opts ) { if ( ! ( this instanceof RedisPool ) ) { return new RedisPool ( opts ) ; } EventEmitter . call ( this ) ; opts = opts || { } ; var defaults = { host : '127.0.0.1' , port : '6379' , max : 50 , idleTimeoutMillis : 10000 , reapIntervalMillis : 1000 , noReadyCheck : false , returnToHead : false , unwatchOnRelease : true , name : 'default' , log : false , slowPool : { log : false , elapsedThreshold : 25 } , emitter : { statusInterval : 60000 } , commands : [ ] } ; this . options = _ . defaults ( opts , defaults ) ; this . pools = { } ; this . elapsedThreshold = this . options . slowPool . elapsedThreshold ; // add custom Redis commands if ( this . options . commands && this . options . commands . length ) { this . options . commands . forEach ( function ( newCommand ) { redis . add_command ( newCommand ) ; } ) ; } var self = this ; setInterval ( function ( ) { Object . keys ( self . pools ) . forEach ( function ( poolKey ) { var pool = self . pools [ poolKey ] ; self . emit ( 'status' , { name : self . options . name , db : poolKey , count : pool . getPoolSize ( ) , unused : pool . availableObjectsCount ( ) , waiting : pool . waitingClientsCount ( ) } ) ; } ) ; } , this . options . emitter . statusInterval ) ; }
Create a new multi database Redis pool.
It will emit `status` event with information about each created pool.

@param {Object} opts
@returns {RedisPool}
@constructor
Create a new multi database Redis pool . It will emit status event with information about each created pool .