Modular Redis connection and PUBSUB subscription manager for node. Easily extendable. Built for performance, powered by ioredis.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
docs
example script loader default fix May 31, 2016
src
test
.babelrc
.editorconfig
.eslintrc linting Sep 23, 2016
.flowconfig
.gitignore
.npmignore
.travis.yml
LICENSE
Makefile
README.md
package.json
test.js

README.md

RediBox

Coverage Status Downloads npm version dependencies build License

Redis connection and PUBSUB subscription manager for node. Built for performance, powered by ioredis (for now). Maintained by TeamFA.

What is it?

RediBox is a NodeJS library which interacts with Redis to provide solutions to common use-cases in your application. It features out of the box support for clusters, sentinels or standalone redis servers. RediBox core provides utilities for managing your Redis client including client connection monitoring, advanced subscriptions via PUBSUB, lua script management and more.

Features

The additional features RediBox offers are provided as extensible hooks which can be used on a per project level:

  • Cache - Flexible data caching service.
  • Job - High performance, robust and flexible queue/worker system.
  • Schedule - Cross server task scheduling.
  • Memset - Synchronised data sets stored in memory across all servers - for quick synchronous access to data that is commonly used but not likely to update frequently.
  • Throttle - Provides lua scripts to throttle things, i.e. 100 inbound http reqs per user every 10secs
  • Trend - Track trending data using Bitly Forget-Table type data structures.
  • API - A JSON API for RediBox (Work in progress).

Getting Started

Install via npm:

npm install redibox --save

If you're looking to integrate this with SailsJS, we've got a hook for that.

And include in your project:

// ES6
import Redibox from 'redibox';

const RediBox = new Redibox({
  redis: {
    port: 7777
  }
}); // optional callback for bootstrap ready status or use events:

RediBox.on('ready', clientStatus => {
  RediBox.log.info(clientStatus); // internal redibox instance of winston if needed.
  // use cache module to set a cached value with a 60 second validity time.
  RediBox.hooks.cache.set('myKey', 'myVal', 60); // use a callback or a promise
});

RediBox.on('error', error => {
  RediBox.log.error(error); // internal redibox instance of winston if needed.
});

For an example of connecting to a cluster see the Cluster Hook documentation.

Configuration

See the default config for all available configuration options.

Documentation

Contributing

Full contributing guidelines are to be written, however please ensure you follow these points when sending in PRs:

  • Ensure no lint warnings occur via npm run lint.
  • Implement tests for new features / functionality.
  • Ensure coverage remains above 80% and does not decrease.
  • Use debug logging throughout for ease of debugging issues, see core.js for example.
  • New modules should follow the same format as the default modules / template.

Note: For debugging purposes you may want to enable verbose logging via the config:

  new RediBox({
    log: {
      level: 'verbose'
    }
  });

License

MIT