redibox
v2.3.0
Published
Redis connection and PUBSUB subscription manager for node. Built for performance, powered by ioredis.
Downloads
94
Readme
RediBox
Redis connection and PUBSUB subscription manager for node. Built for performance, powered by ioredis (for now).
What can you do with RediBox?
RediBox offers out of the box support for clusters, sentinels and standalone redis servers. It also
provides easy utilities around redis client connection monitoring, scaling cluster
reads with READONLY
, advanced subscriptions via PUBSUB (in the
easy to use node.js Event Emitter format), lua script management and executing commands against a cluster.
RediBox is also easily extensible via Hooks.
Getting Started
Install via npm:
npm install redibox --save
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
Hooks
RediBox has a built in hook loading system and has plenty of published hook modules that support many of the common Redis use cases and provide additional functionality.
RediBox Hooks
- Cache - Redis as a cache layer made simple.
- Job - High performance, robust and flexible queue/worker system powered by redis.
- 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.
- Schedule - Cross server task scheduling made easy.
- Throttle - Provides lua scripts to throttle things, i.e. 100 inbound http reqs per user every 10secs
- Trend - Track trending data with Node - using Bitly Forget-Table type data structures.
Public User Hooks
- None
If you would like to publish your own hook and list it here see the extending functionality via Hooks documentation, once published submit a PR to list it on the readme here.
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