Registry / storage / koishi-plugin-cache-redis

koishi-plugin-cache-redis

JSON →
library2.1.3jsnpmunverified

Redis-backed cache service plugin for Koishi bot framework v4.15+. Provides database-agnostic caching with TTL support, LRU eviction, and Redis Sentinel/Cluster compatibility. Current version 2.1.3 supports Koishi 4.15+. Key differentiators: fully typed (TypeScript), zero-dependency beyond Koishi+Redis, dual ESM/CJS exports, and integration with Koishi's schema-driven config. Releases follow Koishi plugin conventions.

npm install koishi-plugin-cache-redis
INSTALL
IMPORT
SIG · KOISHI-PLUGIN-CACH
K
koishi-plugin-cache-redis
storagejavascriptv2.1.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import RedisCache from 'koishi-plugin-cache-redis'
const RedisCache = require('koishi-plugin-cache-redis')
Default import for use in koishi plugin config. CommonJS require works too.
RedisCache
import { RedisCache } from 'koishi-plugin-cache-redis'
import { RedisCache } from 'koishi'
Named export available for programmatic use, but default is recommended.
Cache
import { Cache } from 'koishi'
import { Cache } from 'koishi-plugin-cache-redis'
Cache base class is in koishi, not this plugin.

Initialize Koishi app with Redis cache plugin, connecting to Redis with configurable host, port, and password.

import { App } from 'koishi' import RedisCache from 'koishi-plugin-cache-redis' const app = new App({ port: 8080, plugins: { cache: { $cache: RedisCache, $key: 'myapp', redis: { host: process.env.REDIS_HOST ?? 'localhost', port: Number(process.env.REDIS_PORT) ?? 6379, password: process.env.REDIS_PASSWORD ?? '', }, }, }, }) app.start()
Debug
Known issues
breakingVersion 2.0+ requires Koishi 4.15+; older versions use koishi-plugin-cache@1.x.
fix
Update koishi to ^4.15.0 or use koishi-plugin-cache-redis@1.x.
affects: >=2.0.0
gotchaSetting $key is required for prefix isolation; omitting may cause cache key collisions across plugins.
fix
Set a unique $key in plugin config, e.g., $key: 'mybot'.
affects: >=1.0.0
deprecatedUsing 'localhost' as host without TLS in production exposes Redis traffic.
fix
Configure TLS via redis.tls or use a Redis proxy.
affects: >=1.0.0
gotchaPlugin does not handle Redis cluster failover automatically; use ioredis cluster mode externally.
fix
Wrap ioredis cluster client and pass via redis option.
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'get')
Cache plugin not properly registered before using cache service.
fix
Ensure cache plugin is loaded before any plugin that uses ctx.cache.
Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED
Redis server not running or incorrect host/port.
fix
Start Redis server or check REDIS_HOST/REDIS_PORT environment variables.
ERR AUTH <password> failed
Wrong Redis password in config.
fix
Set correct REDIS_PASSWORD environment variable or remove if no password.
Upgrade
Version history
2.1.3latest on npm
Audit
Dependencies
koishirequiredPeer dependency; plugin extends Koishi's cache service.
Agent activity
23 hits · last 30 days
node
22
OpenAI (training)
1
Resources
koishi-plugin-cache-redis — npm install koishi-plugin-cache-redis · libregistry