Skip to content

Nullmage/express-throttle-memcached

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

express-throttle-memcached

Memcached wrapper for express-throttle

npm version

Installation

$ npm install express-throttle-memcached

Usage

var express = require("express");
var throttle = require("express-throttle");
var memcached = require("memcached");
var MemcachedStore = require("express-throttle-memcached");

var app = express();

// Rolling window
app.post("/search", throttle({
  "burst": 10,
	"rate": "5/s",
	"store": new MemcachedStore(new Memcached())
}), function(req, res, next) {
	// ...
});

// Fixed window
app.post("/search", throttle({
  "burst": 10,
  "period": "1min",
  "store": new MemcachedStore(new Memcached())
}), function(req, res, next) {
  // ...
});

Neither express-throttle nor this package will expire / remove / cleanup any keys. This means that memory usage will grow unbounded as new requests are being processed. Thus, it is recommended to have a separate memcached instance only for throttling purposes with a sensible memory limit. Consult the Memcached documentation for more information.

About

Memcached wrapper for express-throttle

Resources

License

Stars

Watchers

Forks

Packages

No packages published