0.1.9 • Published 9 years ago

gaiden-redis v0.1.9

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

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);
    })
  }
})
0.1.9

9 years ago

0.1.8

10 years ago

0.1.7

10 years ago

0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago