{"id":45234,"library":"koishi-plugin-cache-redis","title":"Koishi Cache Redis Plugin","description":"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.","status":"active","version":"2.1.3","language":"javascript","source_language":"en","source_url":"https://github.com/koishijs/cache","tags":["javascript","bot","chatbot","koishi","plugin","cache","storage","redis","typescript"],"install":[{"cmd":"npm install koishi-plugin-cache-redis","lang":"bash","label":"npm"},{"cmd":"yarn add koishi-plugin-cache-redis","lang":"bash","label":"yarn"},{"cmd":"pnpm add koishi-plugin-cache-redis","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; plugin extends Koishi's cache service.","package":"koishi","optional":false}],"imports":[{"note":"Default import for use in koishi plugin config. CommonJS require works too.","wrong":"const RedisCache = require('koishi-plugin-cache-redis')","symbol":"default","correct":"import RedisCache from 'koishi-plugin-cache-redis'"},{"note":"Named export available for programmatic use, but default is recommended.","wrong":"import { RedisCache } from 'koishi'","symbol":"RedisCache","correct":"import { RedisCache } from 'koishi-plugin-cache-redis'"},{"note":"Cache base class is in koishi, not this plugin.","wrong":"import { Cache } from 'koishi-plugin-cache-redis'","symbol":"Cache","correct":"import { Cache } from 'koishi'"}],"quickstart":{"code":"import { App } from 'koishi'\nimport RedisCache from 'koishi-plugin-cache-redis'\n\nconst app = new App({\n  port: 8080,\n  plugins: {\n    cache: {\n      $cache: RedisCache,\n      $key: 'myapp',\n      redis: {\n        host: process.env.REDIS_HOST ?? 'localhost',\n        port: Number(process.env.REDIS_PORT) ?? 6379,\n        password: process.env.REDIS_PASSWORD ?? '',\n      },\n    },\n  },\n})\n\napp.start()","lang":"typescript","description":"Initialize Koishi app with Redis cache plugin, connecting to Redis with configurable host, port, and password."},"warnings":[{"fix":"Update koishi to ^4.15.0 or use koishi-plugin-cache-redis@1.x.","message":"Version 2.0+ requires Koishi 4.15+; older versions use koishi-plugin-cache@1.x.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Set a unique $key in plugin config, e.g., $key: 'mybot'.","message":"Setting $key is required for prefix isolation; omitting may cause cache key collisions across plugins.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Configure TLS via redis.tls or use a Redis proxy.","message":"Using 'localhost' as host without TLS in production exposes Redis traffic.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Wrap ioredis cluster client and pass via redis option.","message":"Plugin does not handle Redis cluster failover automatically; use ioredis cluster mode externally.","severity":"gotcha","affected_versions":">=2.0.0"}],"env_vars":null,"search_vec":"'2.1.3':32 '4.15':35 'agnost':19 'back':7 'beyond':44 'bot':13,65 'cach':2,8,20,69 'chatbot':66 'compat':29 'config':58 'convent':63 'current':30 'databas':18 'database-agnost':17 'depend':43 'differenti':37 'driven':57 'dual':47 'esm/cjs':48 'evict':25 'export':49 'follow':60 'framework':14 'fulli':38 'integr':51 'javascript':64 'key':36 'koishi':1,12,34,45,53,61,67 'lru':24 'plugin':4,10,62,68 'provid':16 'redi':3,6,27,46,71 'redis-back':5 'releas':59 'schema':56 'schema-driven':55 'sentinel/cluster':28 'servic':9 'storag':70 'support':23,33 'ttl':22 'type':39 'typescript':40,72 'v4.15':15 'version':31 'zero':42 'zero-depend':41","created_at":"2026-06-07T12:54:01.075554+00:00","updated_at":"2026-06-07T12:54:01.075554+00:00","problems":[{"fix":"Ensure cache plugin is loaded before any plugin that uses ctx.cache.","cause":"Cache plugin not properly registered before using cache service.","error":"TypeError: Cannot read properties of undefined (reading 'get')"},{"fix":"Start Redis server or check REDIS_HOST/REDIS_PORT environment variables.","cause":"Redis server not running or incorrect host/port.","error":"Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED"},{"fix":"Set correct REDIS_PASSWORD environment variable or remove if no password.","cause":"Wrong Redis password in config.","error":"ERR AUTH <password> failed"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://cache.koishi.chat/plugins/redis.html","github":"https://github.com/koishijs/cache","docs":null,"changelog":null,"pypi":null,"npm":"koishi-plugin-cache-redis","openapi_spec":null,"status_page":null,"smithery":null,"categories":["storage"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}