# @express-rate-limit/cluster-memory-store 中文文档

规范地址：https://npmcn.com/package/%40express-rate-limit/cluster-memory-store/

版本：0\.3\.1
npm 元数据更新时间：2024-10-14T18:21:18.221Z
中文译文更新时间：2026-11-14T06:01:24.627Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40express-rate-limit/cluster-memory-store
原文对照：https://npmcn.com/package/%40express-rate-limit/cluster-memory-store/?lang=original
项目主页：https://github.com/express-rate-limit/cluster-memory-store
源码仓库：https://github.com/express-rate-limit/cluster-memory-store

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：31.6 kB，10 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- Node.js 要求：\>= 16
- 运行依赖：2 个
- peer 依赖：express-rate-limit \>= 6
- 首次发布：2023-09-25T01:33:53.911Z
- 最新版本发布：2024-10-14T18:21:17.775Z
- 近 30 天下载量：3690（2026-10-14 至 2026-11-12，npm 官方下载统计）
- 已发布版本数：6（近 12 个月 0 个）

## 中文简介

用于有节点的快率限制中间软件的内存存储: Cluster.

## 安装

```sh
npm install @express-rate-limit/cluster-memory-store
```

也可以使用：`pnpm add @express-rate-limit/cluster-memory-store`、`yarn add @express-rate-limit/cluster-memory-store`、`bun add @express-rate-limit/cluster-memory-store`

## README

# 

`cluster-memory-store`

[![tests](https://github.com/express-rate-limit/cluster-memory-store/actions/workflows/ci.yaml/badge.svg)](https://github.com/express-rate-limit/cluster-memory-store/actions/workflows/ci.yaml) [![npm version](https://img.shields.io/npm/v/@express-rate-limit/cluster-memory-store.svg)](https://npmjs.org/package/@express-rate-limit/cluster-memory-store "View this project on NPM") [![npm downloads](https://img.shields.io/npm/dm/@express-rate-limit/cluster-memory-store)](https://www.npmjs.com/package/@express-rate-limit/cluster-memory-store)

一个存储器 [`express-rate-limit`](https://github.com/express-rate-limit/express-rate-limit) 中间软件,用于 [节点.js 集群模块](https://nodejs.org/api/cluster.html)。 。 。 .

## 安装

```sh
npm install @express-rate-limit/cluster-memory-store
```

(单位:千美元)[替代安装方法](https://github.com/express-rate-limit/cluster-memory-store/wiki/Installation-Methods) - 说吧 pnpm,纱线,Github释放等)

## 使用量

**这个软件包需要您使用节点16或以上.**

在主要群组中:

```ts
import { ClusterMemoryStorePrimary } from '@express-rate-limit/cluster-memory-store'

const rateLimiterStore = new ClusterMemoryStorePrimary()
rateLimiterStore.init()
```

每个集群工人:

```ts
import { rateLimit } from 'express-rate-limit'
import { ClusterMemoryStoreWorker } from '@express-rate-limit/cluster-memory-store'

const limiter = rateLimit({
    store: new ClusterMemoryStoreWorker(),
    /* ...*/
})

app.use(limiter)
```

见 `example/` 一个文件夹 [完整实例](https://github.com/express-rate-limit/cluster-memory-store/tree/main/example)。 。 。 .

## 配置

`ClusterMemoryStoreWorker` 选择配置对象 以下选项:

### `prefix`

> `string`

在适用多重费率限额(例如,总限额和更为严格的限额)时 ),将它设定为每个点的独特值,以防止 重复计算访问.

## 使用 PM2, 枪械和其他流程管理器

因为这个商店在初级过程中需要代码执行,所以没有 与需要全面控制初级进程的流程管理人员合作, 插入时包括PM2 `cluster` 模式.

### 总理

与 [总理](https://pm2.keymetrics.io/),使用以下配置:

```
instances: 1,
exec_mode: 'fork',
```

然后编辑你的主要JS文件,包括集群代码,类似于 [此示例](https://github.com/express-rate-limit/cluster-memory-store/blob/8745cb4da4035f84255e1c0146951a0fe2fbcc10/example/server.js)。 。 。 .

这释放了使用PM2的一些好处,因为它已经无法直接使用 管理工人流程.

### 盖特林

[盖特林](https://www.npmjs.com/package/gatling) 目前不兼容 与 `cluster-memory-store`。 。 。 .

## 问题和贡献

如果遇到错误或想要看到添加/更改的东西,请继续 财务报告和审定财务报表 [打开一个问题](https://github.com/express-rate-limitedly/cluster-memory-store/issues/new)来啊! 如果你需要帮助 随便你 [开始讨论](https://github.com/express-rate-limit/cluster-memory-store/discussions/new)来啊!

如果你想捐给图书馆,谢谢! 首先,请读 [贡献指南](https://npmcn.com/package/%40express-rate-limit/cluster-memory-store/contributing.md)。然后你可以拿起任何问题和 固定/执行它!

## 许可证

麻省理工学院 [内森·弗里德利](http://nfriedly.com/) 财务报告和审定财务报表 [车辆 K](https://github.com/gamemaker1)

## 常见问题

### @express-rate-limit/cluster-memory-store 是什么？

用于有节点的快率限制中间软件的内存存储: Cluster\.

### 如何安装 @express-rate-limit/cluster-memory-store？

在项目目录运行 npm install @express-rate-limit/cluster-memory-store，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：express-rate-limit（\>= 6）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @express-rate-limit/cluster-memory-store 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @express-rate-limit/cluster-memory-store 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @express-rate-limit/cluster-memory-store 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>= 16。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @express-rate-limit/cluster-memory-store 可以商用吗？

@express-rate-limit/cluster-memory-store 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @express-rate-limit/cluster-memory-store 的下载量有多少？

根据 npm 官方下载统计，@express-rate-limit/cluster-memory-store 在 2026/10/14 – 2026/11/12 这 30 天内被下载 3,690 次，日均约 123 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @express-rate-limit/cluster-memory-store 还在维护吗？

最新版本 0\.3\.1 发布于 2024/10/15（2 年前）；至今共发布 6 个版本，其中过去 12 个月发布了 0 个；首次发布于 2023/09/25。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

