Rate Limit Memcached
Memcached client for the express-rate-limit middleware.
Installation
$ npm install --save rate-limit-memcached
Usage
Node.js
var RateLimit = require('express-rate-limit');
var Memcached = require('memcached');
var MemcachedStore = require('rate-limit-memcached');
var client = new Memcached(['memcached.example.com:11211']);
var expiration = 20 * 60;
var limiter = new RateLimit({
store: new MemcachedStore({ expiration: expiration, client: client, prefix: 'remoteip:' }),
windowMs: expiration * 1000,
max: 500,
delayMs: 0
});
app.use(limiter);
TypeScript
import * as RateLimit from 'express-rate-limit'
import * as Memcached from 'memcached'
import MemcachedStore from 'rate-limit-memcached'
const client = new Memcached(['memcached.example.com:11211'])
const expiration = 20 * 60
const limiter = new RateLimit({
store: new MemcachedStore({ expiration, client, prefix: 'remoteip:' }),
windowMs: expiration * 1000,
max: 500,
delayMs: 0
})
app.use(limiter)
Contribution
- Fork (https://github.com/linyows/rate-limit-memcached/fork)
- Create a feature branch
- Commit your changes
- Rebase your local changes against the master branch
- Run test suite with the
npm ci
command and confirm that it passes - Create a new Pull Request