Skip to content

Redis-ext extends nodejs redis client with failover support via Redis Sentinel

Notifications You must be signed in to change notification settings

olado/redis-ext

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

Redis-ext extends nodejs redis client with failover support via Redis Sentinels.

It also provides basic job queue implementation.

This module is being used in production environment.

Installation

npm install redis-ext

Usage

Create Sentinel aware connection:

   var redis = require('redis-ext')
   , _sentinels = [
   		{host: "localhost", port: 26379},
   		{host: "localhost", port: 26380}
   ]
   /* possible options:
   * retry_delay - minimum delay before attempting to reconnect, delay will grow up to retry_max_delay if provided
   * retry_max_delay - maximum delay between reconnection attempts
   * connect_timeout - if specified, retries will stop after total time for reconnecting exceeds this number 
   */
   , _options = { retry_max_delay: 10000 }
   , client = redis.createWithSentinel(_sentinels, "mastername", _options);

Create receiving job client:

   var queue = redis.createQueue(function () {
   	return redis.createWithSentinel(_sentinels, "queues", _options);
   }, key, workerFn);

   queue.connect(); // start receiving jobs

Create job queue:

   var queue = redis.createQueue(function () {
   	return redis.createWithSentinel(_sentinels, "queues", _options);
   }, key);

   queue.send(jobdescription);

Author

Laura Doktorova @olado

License

redis-ext is licensed under the MIT License

About

Redis-ext extends nodejs redis client with failover support via Redis Sentinel

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published