antelopejs/redis
OfficialRedis client module with scheduling capabilities
ajs project modules add @antelopejs/redis@antelopejs/redis
The Redis module of AntelopeJS: it connects one shared ioredis client and serves it to the Redis and Redis Scheduler interfaces.
Interfaces
| Interface | Documentation |
|---|---|
@antelopejs/interface-redis | Redis |
@antelopejs/interface-redis-scheduler | Redis Scheduler |
The scheduler runs inside the interface package on top of the Redis client, so this module is all it needs.
Install
ajs project modules add @antelopejs/redis
The command writes the module's default configuration: redis://localhost:6379.
Configuration
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",
},
});
| Key | Description |
|---|---|
url | Redis connection URL. Optional: without it, the client uses the options below, or localhost:6379. |
useMock | Serve an in-memory ioredis-mock client instead of connecting. For tests only. |
| any other key | Passed to the client as ioredis options (host, port, password, db, tls, lazyConnect…). |
The client connects when the module starts, and quits when it stops.
Quick start
In the module that uses Redis, add the interface:
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() waits until the module has connected. For distributed jobs, add @antelopejs/interface-redis-scheduler and read its documentation.
Documentation
- Redis: the
@antelopejs/interface-rediscontract this module implements - Redis Scheduler: the
@antelopejs/interface-redis-schedulercontract this module implements - Configuration: module sources,
configblocks and config variables inantelope.config.ts
Compatibility
| Package | Supported range |
|---|---|
@antelopejs/interface-redis | >=0.0.9 <1.0.0 |
@antelopejs/interface-redis-scheduler | >=0.0.8 <1.0.0 |
@antelopejs/interface-core | >=0.2.4 <1.0.0 |
The module is developed and tested against @antelopejs/core ^1.16.0 on Node.js 24, with ioredis ^5.10.1.
Contributing
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
The tests need no Redis server. Read the contribution guidelines before opening a pull request.