# @antelopejs/redis 中文文档

规范地址：https://npmcn.com/package/%40antelopejs/redis/

版本：1\.1\.0
npm 元数据更新时间：2026-11-04T15:45:28.729Z
中文译文更新时间：2026-11-07T00:00:10.685Z
软件包许可：Apache-2\.0

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

原始 npm 页面：https://www.npmjs.com/package/%40antelopejs/redis
原文对照：https://npmcn.com/package/%40antelopejs/redis/?lang=original
项目主页：https://interfaces.antelopejs.com/docs/redis/introduction
源码仓库：https://github.com/AntelopeJS/redis

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

- 包体积（解压后）：24.5 kB，9 个文件
- 模块格式：CommonJS
- TypeScript 类型：包内自带
- 运行依赖：5 个
- 首次发布：2025-05-08T22:53:18.131Z
- 最新版本发布：2026-11-04T15:45:28.151Z
- 近 30 天下载量：2143（2026-10-06 至 2026-11-04，npm 官方下载统计）
- 已发布版本数：9（近 12 个月 7 个）

## 中文简介

用于羚羊JS的 Redis 模块,执行与 ioredis 的 Redis 和 Redis 调度接口

## 安装

```sh
npm install @antelopejs/redis
```

也可以使用：`pnpm add @antelopejs/redis`、`yarn add @antelopejs/redis`、`bun add @antelopejs/redis`

## README

# `@antelopejs/redis`

[![npm](https://img.shields.io/npm/v/@antelopejs/redis?style=for-the-badge&labelColor=000000&color=000000)](https://www.npmjs.com/package/@antelopejs/redis) [![License](https://img.shields.io/npm/l/@antelopejs/redis?style=for-the-badge&labelColor=000000&color=000000)](https://npmcn.com/package/%40antelopejs/redis/LICENSE) [![Discord](https://img.shields.io/badge/Discord-18181B?logo=discord&style=for-the-badge&color=000000)](https://discord.gg/g4pFt6eXqu) [![Documentation](https://img.shields.io/badge/Docs-18181B?style=for-the-badge&color=000000)](https://interfaces.antelopejs.com/docs/redis/introduction)

羚羊JS的雷迪斯模块. 它连接一个共享 [`ioredis`](https://github.com/redis/ioredis) 客户端并服务于 Redis 和 Redis 调度器接口.

## 接口

| 接口 | 文档 |
| --- | --- |
| [`@antelopejs/interface-redis`](https://github.com/AntelopeJS/interface-redis) | [重写](https://interfaces.antelopejs.com/docs/redis/introduction) |
| [`@antelopejs/interface-redis-scheduler`](https://github.com/AntelopeJS/interface-redis-scheduler) | [重排调度器](https://interfaces.antelopejs.com/docs/redis-scheduler/introduction) |

调度器运行在 Redis 客户端上方的界面包内,因此除了这个模块,它不需要模块.

## 安装

```bash
ajs project modules add @antelopejs/redis
```

命令会写入模块的默认配置, 它连接到 `redis://localhost:6379`。 。 。 .

## 配置

```typescript
import { defineConfig } from "@antelopejs/interface-core/config";

export default defineConfig({
  name: "my-project",
  modules: {
    redis: {
      source: {
        type: "package",
        package: "@antelopejs/redis",
        version: "^1.0.3",
      },
      config: {
        url: "redis://localhost:6379",
        useMock: false,
        lazyConnect: true,
      },
    },
  },
  envOverrides: {
    REDIS_URL: "modules.redis.config.url",
  },
});
```

| 密钥 | 说明 |
| --- | --- |
| `url` | Redis 连接 URL. 可选的 没有它,客户会使用以下选项,或者 `localhost:6379`。 。 。 . |
| `useMock` | 做梦 [`ioredis-mock`](https://github.com/stipsan/ioredis-mock) 客户端而不是连接,而忽略了所有其他密钥。 只能做测试. |
| 任何其它键 | 传递给客户端 [`ioredis` 选项](https://github.com/redis/ioredis#connect-to-redis),例如 `host`, (中文(简体) ), `port`, (中文(简体) ), `password`, (中文(简体) ), `db`, (中文(简体) ), `tls` 或者说 `lazyConnect`。 。 。 . |

模块启动时创建客户端,停止时退出. 与 `lazyConnect: true`,模块在为客户端服务之前等待连接.

## 快开始

在使用Redis的模块中,添加接口:

```bash
pnpm add @antelopejs/interface-redis
```

```typescript
import { GetClient } from "@antelopejs/interface-redis";

const client = await GetClient();
await client.set("greeting", "hello", "EX", 60);
const greeting = await client.get("greeting");
```

`GetClient()` 等待模块启动并设置客户端。 对分布式工作,加 `@antelopejs/interface-redis-scheduler` 读它 [文档](https://interfaces.antelopejs.com/docs/redis-scheduler/introduction)。 。 。 .

## 文档

-   [重写](https://interfaces.antelopejs.com/docs/redis/introduction) 文档 `@antelopejs/interface-redis` 与本模块执行的合同.
-   [重排调度器](https://interfaces.antelopejs.com/docs/redis-scheduler/introduction) 文档 `@antelopejs/interface-redis-scheduler` 与本模块执行的合同.
-   [配置](https://framework.antelopejs.com/docs/concepts/configuration) 文档模块来源, `config` 块和配置变量 `antelope.config.ts`。 。 。 .

## 兼容性

| 软件包 | 支助 | 测试过 |
| --- | --- | --- |
| `@antelopejs/interface-core` | `>=0.2.4 <1.0.0` | `0.2.4` |
| `@antelopejs/interface-redis` | `>=0.0.9 <1.0.0` | `0.0.9` |
| `@antelopejs/interface-redis-scheduler` | `>=0.0.8 <1.0.0` | `0.0.8` |

`.nvmrc` 设置用于发展的节点.js发布,以及 `dependencies` 联 合 国 `package.json` 设置 `ioredis` 范围.

## 捐款

```bash
pnpm install
pnpm dev            # run the playground/ project against redis://127.0.0.1:6379
pnpm lint
pnpm format:check
pnpm knip
pnpm test           # build, then ajs module test with ioredis-mock
```

测试不需要 Redis 服务器 。 读取 [捐款准则](https://npmcn.com/package/%40antelopejs/redis/CONTRIBUTING.md) 在你打开拉动请求之前.

## 许可证

[阿帕奇 - 2.0](https://npmcn.com/package/%40antelopejs/redis/LICENSE)

## 常见问题

### @antelopejs/redis 是什么？

用于羚羊JS的 Redis 模块,执行与 ioredis 的 Redis 和 Redis 调度接口

### 如何安装 @antelopejs/redis？

在项目目录运行 npm install @antelopejs/redis，或使用 pnpm add / yarn add / bun add。

### @antelopejs/redis 支持 TypeScript 吗？

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

### @antelopejs/redis 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @antelopejs/redis 可以商用吗？

@antelopejs/redis 使用 Apache-2\.0 许可。宽松许可：允许商业使用、修改和再分发，并附带明确的专利授权；分发时需保留许可与 NOTICE 文件，修改过的文件要注明改动。以上为概括，不构成法律意见，请以许可原文为准。

### @antelopejs/redis 的下载量有多少？

根据 npm 官方下载统计，@antelopejs/redis 在 2026/10/06 – 2026/11/04 这 30 天内被下载 2,143 次，日均约 71 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @antelopejs/redis 还在维护吗？

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

