Skip to content

Latest commit

 

History

History
52 lines (33 loc) · 649 Bytes

Readme.md

File metadata and controls

52 lines (33 loc) · 649 Bytes

redis-histogram

Redis histogram for node.js

Installation

$ npm install redis-histogram

Example

var Histogram = require('..');
var redis = require('redis');

var hist = new Histogram({
  client: redis.createClient(),
  bins: 10
});

var n = 1000;

while (n--) {
  hist.add(Math.random() * 50 | 0);
}

hist.load(function(err, res){
  console.log(res)
});

API

Histogram(options)

  • client redis client
  • key redis key ["histogram"]
  • bins number of bins [1000]

Histogram#add(value, [fn])

Bin value with optional callback.

Histogram#load(fn)

Load histogram bins.

License

MIT