This package is currently under development and should be consider ALPHA in terms of state. I/We are currently accepting contributions and/or dedicated contributors to help develop and maintain this package.
For more information on contributing please see the contrib message below.
This package's lead maintainer is an employee of Strapi however this package is not officially maintained by Strapi Solutions SAS nor Strapi, Inc. and is currently maintained in the free time of the lead maintainer.
Absolutely no part of this code should be considered covered under any agreement you have with Strapi proper including but not limited to any Enterprise Agreement you have with Strapi.
This plugin utilizes 1 core package:
These are the primary features that are finished or currently being worked on:
The purpose of this package is to have a universal Redis connector for all packages wanting to utilize a Redis database and/or for those wanting to develop custom functions and code within your Strapi project and would prefer a centralized Redis database for various purposes.
A few examples of where Redis could be used within a Strapi application:
If you are currently using this package in your plugin and would like to be featured, please feel free to submit an issue to have your plugin added to the list below:
Supported Strapi Versions:
Strapi Version | Supported | Tested On |
---|---|---|
v3 | ❌ | N/A |
v4.0.x | ✅ | July 2022 |
v4.1.x | ✅ | July 2022 |
v4.2.x | ✅ | July 2022 |
v4.3.x | ✅ | December 2022 |
v4.4.x | ✅ | December 2022 |
v4.5.x | ✅ | December 2022 |
v4.6.x | ✅ | January 2024 |
v4.7.x | ✅ | January 2024 |
v4.8.x | ✅ | January 2024 |
v4.9.x | ✅ | January 2024 |
v4.10.x | ✅ | January 2024 |
v4.11.x | ✅ | January 2024 |
v4.12.x | ✅ | January 2024 |
v4.13.x | ✅ | January 2024 |
v4.14.x | ✅ | January 2024 |
v4.15.x | ✅ | January 2024 |
v4.16.x | ✅ | January 2024 |
v4.17.x | ✅ | January 2024 |
v4.19.x | ✅ | January 2024 |
This plugin will not work with Strapi v3 projects as it utilizes APIs that don't exist in the v3!
Install the plugin in your Strapi project or your Strapi plugin.
# Using Yarn (Recommended)
yarn add strapi-plugin-redis
# Using npm
npm install strapi-plugin-redis --save
WIP
// path ./config/plugins.js
module.exports = {
redis: {
config: {
connections: {
default: {
connection: {
host: '127.0.0.1',
port: 6379,
db: 0,
},
settings: {
debug: false,
},
},
},
},
},
};
// path ./config/plugins.js
module.exports = {
redis: {
config: {
connections: {
default: {
connection: {
sentinels: [
{ host: '192.168.1.101', port: 26379 },
{ host: '192.168.1.102', port: 26379 },
{ host: '192.168.1.103', port: 26379 },
],
name: 'my-redis-replicaSet',
db: 0,
},
settings: {
debug: false,
},
},
},
},
},
};
// path ./config/plugins.js
const { readFileSync } = require('fs');
module.exports = {
redis: {
config: {
connections: {
default: {
connection: {
// @see https://github.com/luin/ioredis/blob/master/API.md#new-redisport-host-options
host: '127.0.0.1',
port: 6379,
db: 0,
username: 'username',
password: 'secret',
// @see https://github.com/luin/ioredis#tls-options
tls: {
ca: readFileSync('cert.pem'),
},
},
settings: {
debug: false,
},
},
},
},
},
};
This plugin directly mounts each Redis DB client and it's config on strapi.redis
Access with: strapi.redis.config
The config key contains the entire plugin config including all ioredis instances configurations. These should not be modified after bootstrapping your Strapi application (aka while the server is running).
Access with: strapi.redis.connections
For each connection either a normal Redis client is created, or if the cluster setting is enabled and you have properly passed in an array of nodes (and optionally any cluster options) a Redis Cluster client.
Accessed with: strapi.redis.connections.default.client
Note you can swap the default key with any other named database you have configured
From here you have full access to the ioredis API.
I/We are actively looking for contributors, maintainers, and others to help shape this package. As this plugins sole purpose within the Strapi community is to be used by other developers and plugin maintainers to help ease the connection to Redis databases.
Instead of reinventing the wheel every time you need to connect to Redis, the hope is to centralize the connections in a single plugin that all plugins can piggy back on.
If interested please feel free to email the lead maintainer Derrick at: derrickmehaffy@gmail.com or ping DMehaffy
on Discord.
Please Note: This package is maintained collectively by the strapi community organization. While there may be a lead maintainer, they are not the sole maintainer of this code and this code does not belong to the lead maintainer.
See the LICENSE file for licensing information.