Gathering detailed insights and metrics for rate-limit-memcached
Gathering detailed insights and metrics for rate-limit-memcached
Gathering detailed insights and metrics for rate-limit-memcached
Gathering detailed insights and metrics for rate-limit-memcached
A rate limiting store for express-rate-limit with Memcached
npm install rate-limit-memcached
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
14 Stars
69 Commits
2 Forks
4 Watching
2 Branches
6 Contributors
Updated on 07 Nov 2024
TypeScript (99.49%)
Shell (0.51%)
Cumulative downloads
Total Downloads
Last day
72.4%
736
Compared to previous day
Last week
31.1%
4,723
Compared to previous week
Last month
25.2%
17,606
Compared to previous month
Last year
15.8%
164,793
Compared to previous year
rate-limit-memcached
A memcached
store for the
express-rate-limit
middleware.
From the npm registry:
1# Using npm 2> npm install express-rate-limit 3# Using yarn or pnpm 4> yarn/pnpm add express-rate-limit
From Github Releases:
1# Using npm 2> npm install https://github.com/express-rate-limit/rate-limit-memcached/releases/download/v{version}/rate-limit-memcached.tgz 3# Using yarn or pnpm 4> yarn/pnpm add https://github.com/express-rate-limit/rate-limit-memcached/releases/download/v{version}/rate-limit-memcached.tgz
Replace {version}
with the version of the package that you want to your, e.g.:
1.0.0
.
This package requires you to use Node 16 or above.
An example of its usage is as follows:
1import { rateLimit } from 'express-rate-limit'
2import { MemcachedStore } from 'rate-limit-memcached'
3
4const limiter = rateLimit({
5 windowMs: 15 * 60 * 1000, // 15 minutes.
6 max: 100, // Limit each IP to 100 requests per `window` (here, per 15 minutes).
7 standardHeaders: 'draft-7', // Return rate limit info in the `RateLimit` header.
8 legacyHeaders: false, // Disable the `X-RateLimit-*` headers.
9 store: new MemcachedStore({
10 // prefix: 'rl:', // The prefix attached to all keys stored in the cache.
11 locations: ['localhost:11211'], // The server location(s), passed directly to Memcached.
12 }),
13})
14
15// Apply the rate limiting middleware to all requests
16app.use(limiter)
prefix
string
The text to prepend to all keys stored by this package in Memcached.
Defaults to rl:
.
client
MemcachedClient
The client used to make requests to the Memcached server. Must have the following methods:
get: (key, callback)
del: (key, callback)
set: (key, value, lifetime, callback)
add: (key, value, lifetime, callback)
incr: (key, delta, callback)
decr: (key, delta, callback)
Here,
key
is a string,value
anddelta
are numbers, andlifetime
is the time in seconds until it expires.
Defaults to an instance of memcached
,
created with the locations
and config
options (see below for details) passed
to it.
locations
A list of memcached servers to store the keys in, passed to the default Memcached client.
Note that the default client is only used if an alternative client
is not
passed to the store.
Defaults to ['localhost:11211']
.
config
object
The configuration passed to the default Memcached client.
Defaults to {}
.
If you encounter a bug or want to see something added/changed, please go ahead and open an issue! If you need help with something, feel free to start a discussion!
If you wish to contribute to the library, thanks! First, please read the contributing guide. Then you can pick up any issue and fix/implement it!
MIT © Tomohisa Oda, Nathan Friedly and Vedant K
No vulnerabilities found.
No security vulnerabilities found.