redis-quick-callback

0.0.2 • Public • Published

redis-quick-callback

NPM

An enhancement to mranney/node-redis that calls back immediately when no connection is present. When a connection is lost, node-redis client takes anywhere between 200ms to 2500ms to callback. One way around this to turn off enable_offline_queue and loose the awesome offline queuing functionality. This client calls back immediately and executes the command asynchronously.

Usage

Create a new client using the same API as mranney/node-redis

var redis = require('redis-quick-callback');
var client = redis.createClient();
client.on('ready', function () {
  // when no connection exists, err is returned immediately, the "set" is queued
  client.set('key', 'value', function (err) {
    console.log(err); // Err: No connection to server
  });
 
  // when redis connection is back, the queued "set" is executed and the value is available
  client.get('key', function (err, data) {
    console.log(data); // 'value'
  });
 
});

Build and Test

The code can be built using gulp as follows

$ gulp 

Tests require redis to be running at localhost:6379

Run tests using

$ npm test

Package Sidebar

Install

npm i redis-quick-callback

Weekly Downloads

2

Version

0.0.2

License

MIT

Last publish

Collaborators

  • sharathprabhal