Registry / database / strapi-plugin-redis

strapi-plugin-redis

JSON →
library1.1.0jsnpmunverified

Community-maintained plugin for centralized Redis connection management in Strapi v4. Version 1.1.0 (August 2022) wraps ioredis to support single nodes and sentinel replicas. Unlike ad-hoc Redis clients, it provides a global connection pool accessible via Strapi's plugin API. Alpha stage: not officially supported by Strapi, limited documentation, no Sharding examples, and infrequent releases.

npm install strapi-plugin-redis
INSTALL
IMPORT
SIG · STRAPI-PLUGIN-REDI
S
strapi-plugin-redis
databasejavascriptv1.1.0
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.

strapi-plugin-redis
module.exports = async ({ strapi }) => { const redis = strapi.plugin('redis'); }
import redis from 'strapi-plugin-redis'
Plugin is loaded via Strapi's plugin system, not imported directly. Use strapi.plugin('redis') in lifecycle methods or services.
RedisConfig
import type { RedisConfig } from 'strapi-plugin-redis/server/config'
TypeScript type for configuration, available from the server config module. Not exported from main entry.
config default export
export default ({ env }) => ({ default: { connection: { host: env('REDIS_HOST'), port: env('REDIS_PORT') } } })
export default { host: 'localhost' }
Config must export a function that returns an object with a 'default' key. Configuration is read from ./config/plugins.js in Strapi.

Enables the plugin in Strapi config and uses the default Redis connection in a bootstrap lifecycle.

// ./config/plugins.js module.exports = ({ env }) => ({ redis: { enabled: true, config: { default: { connection: { host: env('REDIS_HOST', '127.0.0.1'), port: env.int('REDIS_PORT', 6379), db: env.int('REDIS_DB', 0), password: env('REDIS_PASSWORD', '') } } } } }); // ./src/index.js (or lifecycle method) module.exports = { async bootstrap({ strapi }) { const redis = strapi.plugin('redis'); const client = redis.connections.default.client; await client.set('test', 'Hello Strapi Redis!'); const value = await client.get('test'); console.log('Redis value:', value); } };
Debug
Known issues
breakingStrapi v3 is not supported. Only Strapi v4.0.x and above.
fix
Upgrade your Strapi project to v4 or use an alternative Redis connector for Strapi v3.
affects: <= 4.0
deprecatedThe plugin's config format changed after early alpha. Ensure config is a function returning nested object with 'default' key.
fix
Wrap your config object in a function: module.exports = ({ env }) => ({ redis: { enabled: true, config: { default: { ... } } } })
affects: < 1.0
gotchaPlugin does not support cluster mode natively; assumed working but no configuration samples provided.
fix
If you need cluster support, consider using ioredis directly with a custom connection configuration.
affects: <= 1.1.0
gotchaThe 'connections' property is not documented and may change without notice. Use at your own risk.
fix
Pin the plugin version in package.json and test after upgrades.
affects: <= 1.1.0
breakingSentinel configuration requires 'sentinels' array with 'host' and 'port' per node, not a single host string.
fix
Use correct sentinel config: { sentinels: [{ host: 'sentinel1', port: 26379 }], name: 'mymaster' }
affects: <= 1.1.0
Errors
Common errors & fixes
TypeError: strapi.plugin is not a function
Using strapi.plugin before Strapi is fully initialized (e.g., in a module's top-level scope).
fix
Access strapi.plugin inside a lifecycle method like 'bootstrap' or 'register'.
Redis connection refused - connect ECONNREFUSED 127.0.0.1:6379
Redis server is not running or host/port misconfigured.
fix
Ensure Redis is running: redis-server. Check config: host/port, and that password is correct if set.
Error: The plugin 'redis' is not found. Make sure it is installed and enabled.
Plugin not installed or not enabled in config/plugins.js.
fix
Run 'npm install strapi-plugin-redis' and add 'redis: { enabled: true }' to config/plugins.js.
Cannot find module 'ioredis'
Missing peer dependency ioredis.
fix
Install ioredis: npm install ioredis
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies
ioredisrequiredCore Redis client library used for all connections
strapirequiredRequires Strapi v4.x runtime - not compatible with Strapi v3
Agent activity
14 hits · last 30 days
node
12
Meta
1
OpenAI (training)
1
Resources
strapi-plugin-redis — npm install strapi-plugin-redis · libregistry