gaiden-redis
v0.1.9
Published
simple pooled node redis client
Downloads
2
Readme
A module that wraps redis interfaces in connection pooling logic
This library takes in a thrift service and wraps the methods with connection pooling logic (based on node-pool)
Installation
npm install gaiden-redis
Usage - Initialization
var gaiden_redis = require('gaiden-redis');
var redis_options = {};
var pool_options = {};
redis = gaiden_redis(redis_options, pool_options)
Redis options
Check redis createClient
- host - default: '127.0.0.1'
- port - default: 6379
- options - default: {}
Pool options
- max - default: 1
- min - default: 0
- idleTimeoutMillis - default: 39 * 1000
- log - default: false
Usage - Wrapped Command
gaiden-redis
has wrapped redis command, check this list
client = redis.client;
client.set('hello', 'world');
client.get('hello', function(err, result){
console.log(result);
})
Usage - Vanilla Client
client = redis.createClient();
client.psubscribe('channel');
client.on("pmessage", function(pattern, channel, message){
// ......
})
Usage - Generic Pool
Maybe it's not necessary, still I export it anyway.
pool = redis.pool
pool.acquire(function(err, client){
if (err) {
// handle error
} else {
client.set("hello", "world");
client.get("hello", function(err, result){
console.log(result);
pool.release(client);
})
}
})