@antelopejs/interface-redis
Direct access to the Redis client of an AntelopeJS project: one shared connection for caching, counters, pub/sub and any other Redis command.
What it offers
GetClient()resolves to the project's shared ioredis client once the connection is up.- The client exposes every Redis command, transactions and pipelines.
- Every module reuses the one connection that the implementing module opens and configures.
Implementations
| Module | Notes |
|---|---|
@antelopejs/redis | Also implements @antelopejs/interface-redis-scheduler |
Install
Add the interface to the module that talks to Redis:
pnpm add @antelopejs/interface-redis
Then add the implementation to the project:
ajs project modules add @antelopejs/redis
Quick start
import { GetClient } from "@antelopejs/interface-redis";
const CACHE_TTL_SECONDS = 60;
export async function cachePage(path: string, html: string) {
const client = await GetClient();
await client.set(`page:${path}`, html, "EX", CACHE_TTL_SECONDS);
}
export async function readCachedPage(path: string) {
const client = await GetClient();
return await client.get(`page:${path}`);
}
Documentation
Compatibility
Requires AntelopeJS core 1.x and the following peer dependency:
| Package | Range |
|---|---|
@antelopejs/interface-core | >=0.2.4 <1.0.0 |
Driver dependency:
| Package | Range |
|---|---|
ioredis | ^5.10.1 |
Contributing
Read CONTRIBUTING.md before you open a pull request. The local checks are:
pnpm install
pnpm lint
pnpm test