Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

celerity

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

celerity

celerity uses redis to do centralized rate limiting for applications running on multiple heroku dynos

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

celerity

Build Status

celerity uses redis to do centralized rate limiting for applications running on multiple heroku dynos (or processes).

install

npm install celerity

example

see example.js for a simple rate limited webserver using celerity

use

require
var celerity = require('celerity');

var redis = require('redis');
configure
var config = {
    redis: redis.createClient(),
    timespan: 10 * 1000,
    bucketCount: 10
};

celerity keeps the rate for the last timespan milliseconds.

timespan is divided into bucketCount buckets. the rate is stored in the buckets. buckets older than timespan expire every timespan / bucketCount milliseconds.

a higher bucketCount increases the frequency and accuracy of the expires but uses more memory and results in slower read operations. if timespan is several seconds long it is usually enough to have a bucket for every second.

use the prefix property to set a prefix for all redis keys used by celerity. the default prefix is celerity:.

increment(config, event, n, cb)
celerity.increment(config, 'event', 1, function(err) {
});

atomic. complexity: O(1).

read(config, event, cb)
celerity.read(config, 'event', function(err, rate) {
});

atomic. complexity: O(n) where n is bucketCount.

incrementAndRead(config, event, n, cb)
celerity.incrementAndRead(config, 'event', 1, function(err, rate) {
});

atomic. complexity: O(n) where n is bucketCount.

license: MIT

Keywords

FAQs

Package last updated on 03 Oct 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc