diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml
new file mode 100644
index 0000000..8060591
--- /dev/null
+++ b/.github/workflows/deploy-docs.yml
@@ -0,0 +1,53 @@
+name: Deploy Docs to GitHub Pages
+
+on:
+ push:
+ branches:
+ - main
+
+defaults:
+ run:
+ working-directory: docs
+
+jobs:
+ build:
+ name: Build Docusaurus
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+ - uses: actions/setup-node@v4
+ with:
+ node-version: 20
+ cache: yarn
+
+ - name: Install dependencies
+ run: yarn install --frozen-lockfile
+ - name: Build website
+ run: yarn build
+
+ - name: Upload Build Artifact
+ uses: actions/upload-pages-artifact@v3
+ with:
+ path: build
+
+ deploy:
+ name: Deploy to GitHub Pages
+ needs: build
+
+ # Grant GITHUB_TOKEN the permissions required to make a Pages deployment
+ permissions:
+ pages: write # to deploy to Pages
+ id-token: write # to verify the deployment originates from an appropriate source
+
+ # Deploy to the github-pages environment
+ environment:
+ name: github-pages
+ url: ${{ steps.deployment.outputs.page_url }}
+
+ runs-on: ubuntu-latest
+ steps:
+ - name: Deploy to GitHub Pages
+ id: deployment
+ uses: actions/deploy-pages@v4
diff --git a/.github/workflows/test-deploy-docs.yml b/.github/workflows/test-deploy-docs.yml
new file mode 100644
index 0000000..ab2b9d8
--- /dev/null
+++ b/.github/workflows/test-deploy-docs.yml
@@ -0,0 +1,28 @@
+name: Test Deploy Docs to GitHub Pages
+
+on:
+ pull_request:
+ branches:
+ - main
+
+defaults:
+ run:
+ working-directory: docs
+
+jobs:
+ test-deploy:
+ name: Test deployment
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+ - uses: actions/setup-node@v4
+ with:
+ node-version: 20
+ cache: yarn
+
+ - name: Install dependencies
+ run: yarn install --frozen-lockfile
+ - name: Test build website
+ run: yarn build
diff --git a/.markdownlint.json b/.markdownlint.json
new file mode 100644
index 0000000..958784c
--- /dev/null
+++ b/.markdownlint.json
@@ -0,0 +1,5 @@
+{
+ "default": true,
+ "MD033": false,
+ "MD013": false
+}
diff --git a/docs/docs/api/client.md b/docs/docs/api/client.md
index f0be807..4df5b05 100644
--- a/docs/docs/api/client.md
+++ b/docs/docs/api/client.md
@@ -4,3 +4,8 @@ slug: '/api/client'
---
# API 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](https://github.com/luin/ioredis/blob/master/API.md).
diff --git a/docs/docs/api/config.md b/docs/docs/api/config.md
index 1a2d7a3..36aa164 100644
--- a/docs/docs/api/config.md
+++ b/docs/docs/api/config.md
@@ -4,3 +4,7 @@ slug: '/api/config'
---
# API Config
+
+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).
diff --git a/docs/docs/api/connections.md b/docs/docs/api/connections.md
index c2f1749..77d8466 100644
--- a/docs/docs/api/connections.md
+++ b/docs/docs/api/connections.md
@@ -4,3 +4,7 @@ slug: '/api/connections'
---
# API Connections
+
+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.
diff --git a/docs/docs/api/intro.md b/docs/docs/api/intro.md
index 158465e..1e6f497 100644
--- a/docs/docs/api/intro.md
+++ b/docs/docs/api/intro.md
@@ -4,3 +4,7 @@ slug: '/api/intro'
---
# API Introduction
+
+This plugin provides a Redis client for your Strapi application. It is based on the [ioredis](https://github.com/luin/ioredis/blob/master/API.md) package and provides a simple and easy-to-use interface for connecting to a Redis (or Redis alternative) database.
+
+More detailed examples for using this packages API will be coming shortly.
diff --git a/docs/docs/best-practices.md b/docs/docs/best-practices.md
index 6a19de4..dd3c218 100644
--- a/docs/docs/best-practices.md
+++ b/docs/docs/best-practices.md
@@ -4,3 +4,5 @@ slug: '/best-practices'
---
# Best Practices
+
+Best practices will be coming soon, please check back later.
diff --git a/docs/docs/faq.md b/docs/docs/faq.md
index acb2908..1af4907 100644
--- a/docs/docs/faq.md
+++ b/docs/docs/faq.md
@@ -4,3 +4,23 @@ slug: '/faq'
---
# Frequently Asked Questions
+
+## Do you plan on implementing a feature for X?
+
+Probably not unless the feature request has been opened on the [GitHub Repo](https://github.com/strapi-community/plugin-redis) and up voted by the community. However we do also accept PRs for new features.
+
+## How do I contribute to the project?
+
+Please open up a PR on the [GitHub Repo](https://github.com/strapi-community/plugin-redis), we will review it and merge it if it meets our standards. If you would like to discuss something before you contribute you are welcome to open an issue on the repo.
+
+## Do you plan on rewriting this in Typescript or providing Typescript support?
+
+No, we do not plan on rewriting this in Typescript or providing Types. Certainly we will accept PRs if you believe you can provide a good implementation that doesn't overly complicate the code-base but in general you should be able to use the existing types provided by the `ioredis` package.
+
+The Lead maintainer of this package has a strong preference for Javascript over Typescript and does not see the value in rewriting the package in Typescript.
+
+## I can't get the package to work, can you help me?
+
+Please open an issue on the [GitHub Repo](https://github.com/strapi-community/plugin-redis) and we will do our best to help you. Please provide as much information as possible including the version of Strapi you are using, the version of the plugin you are using, and any error messages you are seeing.
+
+Most of the time the issue is not with this plugin and is with your Redis configuration or your Strapi configuration. In many cases certain cloud providers have very strict network firewalls or restrictions that can prevent the connection.
diff --git a/docs/docs/installation.md b/docs/docs/installation.md
index 3b52d0b..c0c773b 100644
--- a/docs/docs/installation.md
+++ b/docs/docs/installation.md
@@ -3,4 +3,60 @@ sidebar_label: 'Installation'
slug: '/installation'
---
+import Tabs from '@theme/Tabs';
+import TabItem from '@theme/TabItem';
+
# Installation
+
+As of plugin version 2.0.0+, the plugin package name has changed to `@strapi-community/plugin-redis`.
+This change was made to align with the naming convention of official Strapi plugins.
+
+As such the following table outlines the plugin versions vs the Strapi versions they are compatible with:
+
+| Strapi Version | Plugin Version |
+|----------------|----------------|
+| 5.x.x | 2.x.x |
+| 4.x.x | 1.x.x |
+| 3.x.x | N/A |
+
+## Installation for Strapi 5.x.x
+
+To install the plugin, run the following command:
+
+
+
+
+```bash
+yarn add @strapi-community/plugin-redis
+```
+
+
+
+
+```bash
+npm install @strapi-community/plugin-redis --save
+```
+
+
+
+
+## Installation for Strapi 4.x.x
+
+To install the plugin, run the following command:
+
+
+
+
+```bash
+yarn add strapi-plugin-redis
+```
+
+
+
+
+```bash
+npm install strapi-plugin-redis --save
+```
+
+
+
diff --git a/docs/docs/introduction.md b/docs/docs/introduction.md
index e535b1a..060b73d 100644
--- a/docs/docs/introduction.md
+++ b/docs/docs/introduction.md
@@ -3,4 +3,32 @@ sidebar_label: 'Introduction'
slug: '/'
---
-# Intro
+# Introduction
+
+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.
+
+This package is a wrapper around the `ioredis` package and provides a simple and easy-to-use interface for connecting to a Redis (or Redis alternative) database.
+
+Likewise, this package also includes the `redlock` package for distributed locks. Currently, if you horizontally scale Strapi and use the cron feature, you will end up with multiple instances of Strapi running the same cron job at the same time, potentially causing race conditions. This can cause issues with your database or other services that you are trying to integrate with. If enabled the Redlock option will automatically force those cron jobs to establish a lock before running the job meaning that only one instance of Strapi will run the job at a time.
+
+## Features
+
+- **Universal Redis Connector**: This package is a universal Redis connector for all packages wanting to utilize a Redis database.
+- **Multiple Redis Connections**: This package supports multiple Redis connections.
+- **Cluster/Sentinel Support**: This package supports Redis Cluster and Redis Sentinel.
+- **Redlock Support**: This package supports Redlock for distributed locks.
+- **Automatic Redlock CronTasks**: This package automatically uses Redlock for Strapi built-in CronTasks.
+
+## Possible Future Features
+
+- **Admin Panel Interface to see all Redis Connections**: This package may include an admin panel interface to see all Redis connections and their status.
+- **Admin Panel Interface to see all Redis Key/Values**: This package may include an admin panel interface to see all Redis keys and their values.
+- **Admin Panel Interface to see all Redis Server Status**: This package may include an admin panel interface to see all Redis server status (memory usage, CPU usage, etc).
+
+## Common Use-cases
+
+- **Caching**: This package can be used for caching data, for example see the LRU based plugin that uses this package called [REST Cache](/plugins/rest-cache).
+- **Apollo Server GraphQL Cache**: This package can be used for caching Apollo Server GraphQL data.
+- **IP based Rate Limiting**: This package can be used for IP based rate limiting using something like [koa2-ratelimit](https://www.npmjs.com/package/koa2-ratelimit).
+- **Server-side User Sessions**: This package can be used for server-side user session storage and management.
+- **So Much More**: The possibilities are endless!
diff --git a/docs/docs/plugins/rest-cache.md b/docs/docs/plugins/rest-cache.md
index 1edc49f..6cd547e 100644
--- a/docs/docs/plugins/rest-cache.md
+++ b/docs/docs/plugins/rest-cache.md
@@ -4,3 +4,5 @@ slug: '/plugins/rest-cache'
---
# REST Cache Plugin
+
+Details on this plugin are coming soon! Please check back later.
diff --git a/docs/docs/redis/basic.md b/docs/docs/redis/basic.md
index dc29fc9..26c219d 100644
--- a/docs/docs/redis/basic.md
+++ b/docs/docs/redis/basic.md
@@ -4,3 +4,32 @@ slug: '/redis/basic'
---
# Basic Single Node Config
+
+The default configuration for the Redis plugin is a single node configuration. This is the most common configuration for Redis and is the default configuration for the plugin.
+
+```javascript
+// path ./config/plugins.js
+
+module.exports = {
+ redis: {
+ config: {
+ settings:{
+ debug: false,
+ enableRedlock: true,
+ }
+ connections: {
+ default: {
+ connection: {
+ host: '127.0.0.1',
+ port: 6379,
+ db: 0,
+ },
+ settings: {
+ debug: false,
+ },
+ },
+ },
+ },
+ },
+};
+```
diff --git a/docs/docs/redis/cluster.md b/docs/docs/redis/cluster.md
index f36121f..3bec86c 100644
--- a/docs/docs/redis/cluster.md
+++ b/docs/docs/redis/cluster.md
@@ -4,3 +4,5 @@ slug: '/redis/cluster'
---
# Cluster Config
+
+Cluster Configuration enable coming soon! Please check back later.
diff --git a/docs/docs/redis/intro.md b/docs/docs/redis/intro.md
index b5593e2..3f51a60 100644
--- a/docs/docs/redis/intro.md
+++ b/docs/docs/redis/intro.md
@@ -4,3 +4,32 @@ slug: '/redis/intro'
---
# Configuration Introduction
+
+The Redis plugin for Strapi is a simple wrapper around the [ioredis](https://github.com/luin/ioredis) package but also includes the [redlock](https://www.npmjs.com/package/redlock) package for distributed locks. This plugin provides a simple and easy-to-use interface for connecting to a Redis (or Redis alternative) database.
+
+## Complete Configuration
+
+This configuration table does not include **all possible options** as many of them come from [ioredis](https://github.com/luin/ioredis) directly and what is shown here is mostly those options related to the plugin specifically and showing the default values.
+
+| Key | Description | Type | Default |
+|-------------------------------------------|---------------------------------------------------|---------|-------------|
+| `settings` | The settings for the Redis plugin. | Object | N/A |
+| `settings.debug` | Whether to enable debug mode. | Boolean | `false` |
+| `settings.debugIORedis` | Whether to enable debug mode for ioredis. | Boolean | `false` |
+| `settings.enableRedlock` | Whether to enable redlock for distributed locks. | Boolean | `false` |
+| `settings.lockDelay` | The delay in milliseconds for the lock. | Number | `null` |
+| `settings.lockTTL` | The time-to-live in milliseconds for the lock. | Number | `5000` |
+| `settings.redlockConfig` | The redlock configuration. | Object | N/A |
+| `settings.redlockConfig.driftFactor` | The drift factor for redlock. | Number | `0.01` |
+| `settings.redlockConfig.retryCount` | The retry count for redlock. | Number | `10` |
+| `settings.redlockConfig.retryDelay` | The retry delay for redlock. | Number | `200` |
+| `settings.redlockConfig.retryJitter` | The retry jitter for redlock. | Number | `200` |
+| `connections` | The connections for the Redis plugin. | Object | N/A |
+| `connections.default` | The default connection for the Redis plugin. | Object | N/A |
+| `connections.default.connection` | The object passed to ioredis directly | Object | N/A |
+| `connections.default.connection.host` | The host for the connection. | String | `127.0.0.1` |
+| `connections.default.connection.port` | The port for the connection. | Number | `6379` |
+| `connections.default.connection.password` | The password for the connection. | String | `null` |
+| `connections.default.connection.db` | The database for the connection. | Number | `0` |
+| `connections.default.settings` | The settings for the connection. | Object | N/A |
+| `connections.default.settings.debug` | Whether to enable debug mode for this connection. | Boolean | `false` |
diff --git a/docs/docs/redis/redlock.md b/docs/docs/redis/redlock.md
index 961ed99..7ec67b6 100644
--- a/docs/docs/redis/redlock.md
+++ b/docs/docs/redis/redlock.md
@@ -4,3 +4,75 @@ slug: '/redis/redlock'
---
# Redlock Config
+
+Redlock configuration is fairly easy to get setup and additional details for using it within Strapi's Crontasks is also lightly detailed below.
+
+```javascript
+// path ./config/plugins.js
+
+module.exports = {
+ redis: {
+ config: {
+ settings:{
+ enableRedlock: true,
+ lockDelay: null,
+ lockTTL: 5000,
+ redlockConfig: {
+ driftFactor: 0.01,
+ retryCount: 10,
+ retryDelay: 200,
+ retryJitter: 200,
+ },
+ },
+ connections: {
+ //...
+ },
+ },
+ },
+};
+```
+
+## Cron Task Example
+
+Adding the bypassRedlock property to your cron job will bypass the redlock logic and allow multiple instances of Strapi to run the same cron job at the same time.
+
+This plugin requires you to use the object format of the cron config. i.e if you are using the rule as the key, you will need to change it to an object with the rule as a property and the key as a unique name. This is because across your Strapi instances, Redis needs to lock onto a key that is the same across all instances.
+
+### Normal Cron Task Example
+
+```javascript
+// path ./config/cron-tasks.js
+
+module.exports = {
+ myJob: {
+ task: ({ strapi }) => {/* Add your own logic here */ },
+ bypassRedlock: false, // optional
+ options: {
+ rule: '0 0 1 * * 1',
+ },
+ },
+};
+```
+
+### Bootstrap Example
+
+```javascript
+// path ./src/index.js
+
+module.exports = {
+ register(/* { Strapi } */) {},
+ bootstrap({ strapi }) {
+ strapi.cron.add({
+ myJob: {
+ task: async ({ strapi }) => {
+ console.log("hello from bootstrap")
+ },
+ bypassRedlock: false, // optional
+ options: {
+ rule: '*/10 * * * * *',
+ }
+ },
+ });
+ }
+};
+```
diff --git a/docs/docs/redis/sentinel.md b/docs/docs/redis/sentinel.md
index e02a65e..f2eb7bd 100644
--- a/docs/docs/redis/sentinel.md
+++ b/docs/docs/redis/sentinel.md
@@ -3,4 +3,37 @@ sidebar_label: 'Sentinel'
slug: '/redis/sentinel'
---
-# Redis Sentinel Config
+# Redis Sentinel Replica Config (3 Node)
+
+The Redis plugin supports Redis Sentinel for high availability and failover. This is a common configuration for Redis in production environments.
+
+```javascript
+// path ./config/plugins.js
+
+module.exports = {
+ redis: {
+ config: {
+ settings:{
+ debug: false,
+ enableRedlock: true,
+ }
+ 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,
+ },
+ },
+ },
+ },
+ },
+};
+```
diff --git a/docs/docs/redis/tls-auth.md b/docs/docs/redis/tls-auth.md
index 902cc81..9153b46 100644
--- a/docs/docs/redis/tls-auth.md
+++ b/docs/docs/redis/tls-auth.md
@@ -4,3 +4,40 @@ slug: '/redis/tls-auth'
---
# TLS Authentication
+
+To enable TLS authentication, you need to provide the `tls` option in the connection configuration and load in the necessary certificates.
+
+```javascript
+// path ./config/plugins.js
+const { readFileSync } = require('fs');
+
+module.exports = {
+ redis: {
+ config: {
+ settings:{
+ debug: false,
+ enableRedlock: true,
+ },
+ 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,
+ },
+ },
+ },
+ },
+ },
+};
+```
diff --git a/docs/sidebars.js b/docs/sidebars.js
index a5bd024..113f5ad 100644
--- a/docs/sidebars.js
+++ b/docs/sidebars.js
@@ -24,11 +24,11 @@ const sidebars = {
label: 'Configuration',
items: [
'redis/intro',
- 'redis/redlock',
'redis/basic',
'redis/sentinel',
- 'redis/cluster',
'redis/tls-auth',
+ 'redis/cluster',
+ 'redis/redlock',
],
collapsed: false,
},