Explorar el Código

add: redis-cluster (#1981)

hareku hace 6 años
padre
commit
14ee775e39
Se han modificado 4 ficheros con 53 adiciones y 0 borrados
  1. 38 0
      DOCUMENTATION/content/documentation/index.md
  2. 8 0
      docker-compose.yml
  3. 4 0
      env-example
  4. 3 0
      redis-cluster/Dockerfile

+ 38 - 0
DOCUMENTATION/content/documentation/index.md

@@ -708,6 +708,44 @@ composer require predis/predis:^1.0
 
 
 
+<br>
+<a name="Use-Redis-Cluster"></a>
+## Use Redis Cluster
+
+1 - First make sure you run the Redis-Cluster Container (`redis-cluster`) with the `docker-compose up` command.
+
+```bash
+docker-compose up -d redis-cluster
+```
+
+2 - Open your Laravel's `config/database.php` and set the redis cluster configuration. Below is example configuration with phpredis.
+
+Read the [Laravel official documentation](https://laravel.com/docs/5.7/redis#configuration) for more details.
+
+```php
+'redis' => [
+    'client' => 'phpredis',
+    'options' => [
+        'cluster' => 'redis',
+    ],
+    'clusters' => [
+        'default' => [
+            [
+                'host' => 'redis-cluster',
+                'password' => null,
+                'port' => 7000,
+                'database' => 0,
+            ],
+        ],
+    ],
+],
+```
+
+
+
+
+
+
 <br>
 <a name="Use-Mongo"></a>
 ## Use Mongo

+ 8 - 0
docker-compose.yml

@@ -456,6 +456,14 @@ services:
       networks:
         - backend
 
+### Redis Cluster ##########################################
+    redis-cluster:
+      build: ./redis-cluster
+      ports:
+        - "${REDIS_CLUSTER_PORT_RANGE}:7000-7005"
+      networks:
+        - backend
+
 ### ZooKeeper #########################################
     zookeeper:
       build: ./zookeeper

+ 4 - 0
env-example

@@ -220,6 +220,10 @@ MYSQL_ENTRYPOINT_INITDB=./mysql/docker-entrypoint-initdb.d
 
 REDIS_PORT=6379
 
+### REDIS CLUSTER #########################################
+
+REDIS_CLUSTER_PORT_RANGE=7000-7005
+
 ### ZooKeeper #############################################
 
 ZOOKEEPER_PORT=2181

+ 3 - 0
redis-cluster/Dockerfile

@@ -0,0 +1,3 @@
+FROM grokzen/redis-cluster:latest
+
+LABEL maintainer="hareku <hareku908@gmail.com>"