@antelopejs/redis
羚羊JS的雷迪斯模块. 它连接一个共享 ioredis 客户端并服务于 Redis 和 Redis 调度器接口.
接口
| 接口 | 文档 |
|---|---|
@antelopejs/interface-redis | 重写 |
@antelopejs/interface-redis-scheduler | 重排调度器 |
调度器运行在 Redis 客户端上方的界面包内,因此除了这个模块,它不需要模块.
安装
ajs project modules add @antelopejs/redis
命令会写入模块的默认配置, 它连接到 redis://localhost:6379。 。 。 .
配置
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 客户端而不是连接,而忽略了所有其他密钥。 只能做测试. |
| 任何其它键 | 传递给客户端 ioredis 选项,例如 host, (中文(简体) ), port, (中文(简体) ), password, (中文(简体) ), db, (中文(简体) ), tls 或者说 lazyConnect。 。 。 . |
模块启动时创建客户端,停止时退出. 与 lazyConnect: true,模块在为客户端服务之前等待连接.
快开始
在使用Redis的模块中,添加接口:
pnpm add @antelopejs/interface-redis
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 读它 文档。 。 。 .
文档
- 重写 文档
@antelopejs/interface-redis与本模块执行的合同. - 重排调度器 文档
@antelopejs/interface-redis-scheduler与本模块执行的合同. - 配置 文档模块来源,
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 范围.
捐款
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 服务器 。 读取 捐款准则 在你打开拉动请求之前.