express-throttle-memcached
v0.0.2
Published
Memcached wrapper for express-throttle
Downloads
5
Readme
express-throttle-memcached
Memcached wrapper for express-throttle
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.