redis-connection-pool
Advanced tools
Comparing version 0.0.2 to 0.0.3
{ | ||
"name": "redis-connection-pool", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Redis client connection pool", | ||
@@ -39,2 +39,2 @@ "license": "AGPL", | ||
"homepage": "https://github.com/silverbucekt/node-redis-connection-pool" | ||
} | ||
} |
@@ -7,6 +7,7 @@ node-redis-connection-pool | ||
## About | ||
node-redis-connection-pool is high-level redis management object. It manages a number of | ||
connections in a pool, using them as needed and keeping all aspects of | ||
releasing active connections internal to the object, so the user does not need | ||
to worry about forgotten connections leaking memory and building up over time. | ||
node-redis-connection-pool is high-level redis management object. It manages | ||
a number of connections in a pool, using them as needed and keeping all aspects | ||
of releasing active connections internal to the object, so the user does not | ||
need to worry about forgotten connections leaking memory and building up over | ||
time. | ||
@@ -83,1 +84,5 @@ ## Installation | ||
Licensed under the [AGPLv3](https://github.com/silverbucket/node-redis-connection-pool/blob/master/LICENSE) | ||
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/silverbucket/node-redis-connectoin-pool/trend.png)](https://bitdeli.com/free "Bitdeli Badge") | ||
@@ -107,3 +107,5 @@ /** | ||
BLOCKING_SUPPORT: true, | ||
PERFORM_CHECKS: false | ||
PERFORM_CHECKS: false, | ||
VERSION_ARRAY: undefined, | ||
VERSION_STRING: undefined | ||
}; | ||
@@ -316,4 +318,20 @@ | ||
/** | ||
* Function: check | ||
* | ||
* Performs a check on redis version and sets internal config based on support. | ||
* | ||
* This function is for compatibility checking, you don't normally need this. | ||
* | ||
* Returns: | ||
* | ||
* promise which, on completion will return a version number as a string. | ||
*/ | ||
RedisConnectionPool.prototype.check = function () { | ||
return redisCheck.apply(this, []); | ||
}; | ||
function redisSingle (funcName, key) { | ||
@@ -328,3 +346,2 @@ var pool = this.pool; | ||
function _setFuncs(funcName, key, field, data, cb) { | ||
@@ -489,3 +506,3 @@ var pool = this.pool; | ||
var self = this; | ||
console.log("redis-connection-pool: checking redis connection at " + self.HOST + ':' + self.PORT); | ||
//console.log("redis-connection-pool: checking redis connection at " + self.HOST + ':' + self.PORT); | ||
var client = redis.createClient(self.PORT, self.HOST); | ||
@@ -498,11 +515,13 @@ try { | ||
client.on('ready', function () { | ||
console.log('redis version: '+client.server_info.redis_version); | ||
var v = client.server_info.versions; | ||
if (v[0] < 2) { | ||
//console.log('redis version: '+client.server_info.redis_version); | ||
self.VERSION_STRING = client.server_info.redis_version; | ||
self.VERSION_ARRAY = client.server_info.versions; | ||
if (self.VERSION_ARRAY[0] < 2) { | ||
self.BLOCKING_SUPPORT = false; | ||
} | ||
client.quit(); | ||
q.resolve(client.server_info.redis_version); | ||
q.resolve(self.VERSION_STRING); | ||
}); | ||
} catch (e) { | ||
console.log('ERROR redis-connection-pool: cannot connect to redis, ' + e); | ||
q.reject('cannot connect to redis: ' + e); | ||
@@ -509,0 +528,0 @@ client.quit(); |
@@ -35,2 +35,21 @@ if (typeof define !== 'function') { | ||
{ | ||
desc: "verify version properties are set", | ||
timeout: 2000, | ||
run: function (env, test) { | ||
test.assertTypeAnd(env.redisPool.VERSION_STRING, 'string'); | ||
test.assertType(env.redisPool.VERSION_ARRAY, 'object'); | ||
} | ||
}, | ||
{ | ||
desc: "#check()", | ||
timeout: 2000, | ||
run: function (env, test) { | ||
env.redisPool.check().then(function (redis_version) { | ||
test.assertType(redis_version, 'string'); | ||
}); | ||
} | ||
}, | ||
{ | ||
desc: "#set", | ||
@@ -37,0 +56,0 @@ timeout: 2000, |
245824
3520
87