redis-connection-pool
Advanced tools
Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "redis-connection-pool", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Redis client connection pool", | ||
@@ -5,0 +5,0 @@ "license": "AGPL", |
@@ -43,2 +43,7 @@ node-redis-connection-pool | ||
* **hgetall** | ||
``` | ||
hgetall(key, callback) | ||
``` | ||
* **hset** | ||
@@ -45,0 +50,0 @@ ``` |
@@ -205,2 +205,17 @@ /** | ||
/** | ||
* Function: hgetall | ||
* | ||
* Execute a redis HGETALL command | ||
* | ||
* Parameters: | ||
* | ||
* key - (string) - The key of the hash you wish to get | ||
* cb - (function) - Callback to be executed on completion | ||
* | ||
*/ | ||
RedisConnectionPool.prototype.hgetall = function (key, cb) { | ||
_getFuncs.apply(this, ['hgetall', key, cb]); | ||
}; | ||
/** | ||
* Function: rpush | ||
@@ -384,2 +399,4 @@ * | ||
redisHashGet.apply(self, [client, key, field, cb]); | ||
} else if (funcName === 'hgetall') { | ||
redisHashGet.apply(self, [client, key, null, cb]); | ||
} | ||
@@ -416,20 +433,23 @@ }); | ||
//console.log('REDIS POOL: get ID: ' + client.__name + ' to key ' + key + ' field:' + key); | ||
var responded = false; | ||
client.hget(key, field, function (err, replies) { | ||
responded = true; | ||
pool.release(client); | ||
if (err) { | ||
console.log('ERROR: redis error (hget '+key+')', err); | ||
cb(err, null); | ||
} else { | ||
cb(err, replies); | ||
} | ||
}); | ||
setTimeout(function() { | ||
if (!responded) { | ||
console.log('ERROR: redis.hget never returned (5s), destroying connection. '+key); | ||
pool.destroy(client); | ||
} | ||
}, 5000); | ||
if (field) { | ||
client.hget(key, field, function (err, replies) { | ||
pool.release(client); | ||
if (err) { | ||
console.log('ERROR: redis error (hget '+key+')', err); | ||
cb(err, null); | ||
} else { | ||
cb(err, replies); | ||
} | ||
}); | ||
} else { | ||
client.hgetall(key, function (err, replies) { | ||
pool.release(client); | ||
if (err) { | ||
console.log('ERROR: redis error (hget '+key+')', err); | ||
cb(err, null); | ||
} else { | ||
cb(err, replies); | ||
} | ||
}); | ||
} | ||
} | ||
@@ -436,0 +456,0 @@ |
@@ -74,2 +74,31 @@ if (typeof define !== 'function') { | ||
{ | ||
desc: "#hset", | ||
run: function (env, test) { | ||
env.redisPool.hset(env.channel + 'testhash', 'foo', 'bar', function (err, reply) { | ||
test.assertAnd(err, null); | ||
env.redisPool.hset(env.channel + 'testhash', 'john', 'doe', function (err, reply) { | ||
test.assertAnd(err, null); | ||
env.redisPool.hset(env.channel + 'testhash', 'super', 'dong', function (err, reply) { | ||
test.assertAnd(err, null); | ||
env.redisPool.hset(env.channel + 'testhash', 'cau', 'sau', function (err, reply) { | ||
test.assert(err, null); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} | ||
}, | ||
{ | ||
desc: "#hgetall", | ||
run: function (env, test) { | ||
env.redisPool.hget(env.channel + 'testhash', function (err, reply) { | ||
test.assertAnd(err, null); | ||
console.log('reply:', reply); | ||
test.assert(reply, { foo: 'bar', john: 'doe', super: 'dong', cau: 'sau' }); | ||
}); | ||
} | ||
}, | ||
{ | ||
desc: "#rpush", | ||
@@ -76,0 +105,0 @@ run: function (env, test) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
244554
3485
82