You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

redis-connection-pool

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redis-connection-pool - npm Package Compare versions

Comparing version

to
0.1.1

doc/files/redis-connection-pool-js.html

2

doc/.config/Menu.txt

@@ -49,3 +49,3 @@ Format: 1.52

File: redis-pool.js (redis-pool.js)
File: redis-connection-pool.js (redis-connection-pool.js)

@@ -52,0 +52,0 @@ Group: Index {

@@ -66,6 +66,6 @@ var indexSectionsWithContent = {

"A": false,
"B": false,
"C": false,
"B": true,
"C": true,
"D": true,
"E": false,
"E": true,
"F": false,

@@ -77,3 +77,3 @@ "G": true,

"K": false,
"L": false,
"L": true,
"M": false,

@@ -80,0 +80,0 @@ "N": false,

{
"name": "redis-connection-pool",
"version": "0.1.0",
"version": "0.1.1",
"description": "a redis client connection pool",

@@ -5,0 +5,0 @@ "license": "LGPL",

/**
* redis-connection-pool.js
*
* copyright 2012-2013 Nick Jennings (https://github.com/silverbucket)
* copyright 2012-2014 Nick Jennings (https://github.com/silverbucket)
*
* licensed under the AGPLv3.
* licensed under the LGPL.
* See the LICENSE file for details.

@@ -58,7 +58,7 @@ *

function RedisConnectionPool(uid, cfg) {
this.UID = (typeof uid ==='string') ? uid : this.UID + Math.floor((Math.random() * 99999) + 10000);
this.DEBUG = (typeof cfg.DEBUG === 'boolean') ? cfg.DEBUG : this.DEBUG;
this.HOST = (typeof cfg.HOST === 'string') ? cfg.HOST : this.HOST;
this.PORT = (typeof cfg.PORT === 'number') ? cfg.PORT : this.PORT;
this.MAX_CLIENTS = (typeof cfg.MAX_CLIENTS === 'number') ? cfg.MAX_CLIENTS : this.MAX_CLIENTS;
this.UID = (typeof uid ==='string') ? uid : this.UID + Math.floor((Math.random() * 99999) + 10000);
this.DEBUG = (typeof cfg.DEBUG === 'boolean') ? cfg.DEBUG : this.DEBUG;
this.HOST = (typeof cfg.HOST === 'string') ? cfg.HOST : this.HOST;
this.PORT = (typeof cfg.PORT === 'number') ? cfg.PORT : this.PORT;
this.MAX_CLIENTS = (typeof cfg.MAX_CLIENTS === 'number') ? cfg.MAX_CLIENTS : this.MAX_CLIENTS;
this.PERFORM_CHECKS = (typeof cfg.PERFORM_CHECKS === 'boolean') ? cfg.PERFORM_CHECKS : this.PERFORM_CHECKS;

@@ -93,3 +93,5 @@ var self = this;

// periodically report pool statistics
console.log('REDIS POOL: [size: '+pool.getPoolSize()+' avail:'+pool.availableObjectsCount()+' waiting:'+pool.waitingClientsCount()+']');
console.log('REDIS POOL: [size: ' + pool.getPoolSize() +
' avail:' + pool.availableObjectsCount() +
' waiting:' + pool.waitingClientsCount() + ']');
setTimeout(poolStats, 300000);

@@ -102,2 +104,3 @@ }, 300000);

}
RedisConnectionPool.prototype = {

@@ -319,3 +322,2 @@ UID: 'redis-connection-pool-',

client.quit();
//console.log('redis-connection-pool: keys ', keys);
if ((keys) && (keys.forEach)) {

@@ -327,6 +329,6 @@ keys.forEach(function (name, pos) {

} else {
console.log('ERROR redis-connection-pool: couldnt get keys list on key \''+key+'\': ', keys);
console.log('ERROR redis-connection-pool: couldnt get keys list on key \'' + key + '\': ', keys);
}
if (err) {
console.log('ERROR redis-connection-pool: failed clearing redis queue. '+err);
console.log('ERROR redis-connection-pool: failed clearing redis queue. ' + err);
}

@@ -370,2 +372,3 @@ cb();

function _setFuncs(funcName, key, field, data, cb) {

@@ -380,4 +383,2 @@ var pool = this.pool;

pool.acquire(function (err, client) {
// console.log('redis-connection-pool: ' + funcName + ' ID: ' + client.__name +
// ' to key ' + key + ' field: '+ field + ' (func:'+typeof cb+') DATA: ', data);
if (funcName === 'hset') {

@@ -394,3 +395,2 @@ client[funcName](key, field, data, function (err, reply) {

} else if (funcName === 'set') {
//console.log('--- key ('+typeof key+'): ' + key + ' DATA ('+typeof data+'): ', data);
client[funcName](key, data, function (err, reply) {

@@ -406,8 +406,2 @@ pool.release(client);

} else {
// if ((typeof data === 'undefined') || (typeof data === 'function')) {
// cb = data;
// data = field;
// field = null;
// }
//console.log('--- field ('+typeof field+'): '+field+' DATA ('+typeof data+'): ', data);
client[funcName](key, data, function (err, reply) {

@@ -434,5 +428,4 @@ pool.release(client);

}
//console.log('redis-connection-pool: getFuncs('+funcName+', '+key+', '+field+', '+typeof cb);
pool.acquire(function (err, client) {
if ((funcName === 'get') || (funcName === 'hgetall')) {

@@ -452,6 +445,5 @@ redisGet.apply(self, [funcName, client, key, cb]);

// works for get and hgetall
function redisGet(funcName, client, key, cb) {
var pool = this.pool;
//console.log('REDIS POOL: get ID: ' + client.__name + ' to key ' + key);
var responded = false;

@@ -462,3 +454,3 @@ client[funcName](key, function (err, replies) {

if (err) {
console.log('ERROR: redis error ('+funcName+' '+key+')', err);
console.log('ERROR: redis error (' + funcName + ' ' + key + ')', err);
cb(err, null);

@@ -472,3 +464,3 @@ } else {

if (!responded) {
console.log('ERROR: redis.'+funcName+' never returned (5s), destroying connection. '+key);
console.log('ERROR: redis.' + funcName+' never returned (5s), destroying connection. ' + key);
pool.destroy(client);

@@ -479,5 +471,5 @@ }

function redisHashGet(client, key, field, cb) {
var pool = this.pool;
//console.log('REDIS POOL: get ID: ' + client.__name + ' to key ' + key + ' field:' + key);
if (field) {

@@ -487,3 +479,3 @@ client.hget(key, field, function (err, replies) {

if (err) {
console.log('ERROR: redis error (hget '+key+')', err);
console.log('ERROR: redis error (hget ' + key + ')', err);
cb(err, null);

@@ -498,3 +490,3 @@ } else {

if (err) {
console.log('ERROR: redis error (hget '+key+')', err);
console.log('ERROR: redis error (hget ' + key + ')', err);
cb(err, null);

@@ -508,5 +500,5 @@ } else {

function redisBlockingGet(funcName, client, key, cb) {
var pool = this.pool;
//console.log(' [util] --- '+funcName+' ID: ' + client.__name + ' to key ' + key);
var responded = false;

@@ -523,21 +515,11 @@ client[funcName](key, 0, function (err, replies) {

} else {
//console.log(funcName + ' received: ', replies);
cb(err, replies);
}
});
// var minutes = 0;
// setTimeout(function reportClient() {
// if (!responded) {
// minutes = minutes + 1;
// console.log(' [util] still waiting '+minutes+'m ['+funcName+':'+client.__name+' '+key+']');
// setTimeout(reportClient, 60000);
// }
// }, 60000);
}
function redisCheck() {
var q = Q.defer();
var self = this;
//console.log("redis-connection-pool: checking redis connection at " + self.HOST + ':' + self.PORT);
var client = redis.createClient(self.PORT, self.HOST);

@@ -550,3 +532,2 @@ try {

client.on('ready', function () {
//console.log('redis version: '+client.server_info.redis_version);
self.VERSION_STRING = client.server_info.redis_version;

@@ -569,3 +550,2 @@ self.VERSION_ARRAY = client.server_info.versions;

var RedisConnectionPoolWrapper;

@@ -594,2 +574,3 @@ (function () {

return RedisConnectionPoolWrapper(uid, cfg);
};
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet