Skip to content

Commit 14ee775

Browse files
harekubestlong
authored andcommitted
add: redis-cluster (laradock#1981)
1 parent 1282c41 commit 14ee775

4 files changed

Lines changed: 53 additions & 0 deletions

File tree

DOCUMENTATION/content/documentation/index.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,44 @@ composer require predis/predis:^1.0
708708

709709

710710

711+
<br>
712+
<a name="Use-Redis-Cluster"></a>
713+
## Use Redis Cluster
714+
715+
1 - First make sure you run the Redis-Cluster Container (`redis-cluster`) with the `docker-compose up` command.
716+
717+
```bash
718+
docker-compose up -d redis-cluster
719+
```
720+
721+
2 - Open your Laravel's `config/database.php` and set the redis cluster configuration. Below is example configuration with phpredis.
722+
723+
Read the [Laravel official documentation](https://laravel.com/docs/5.7/redis#configuration) for more details.
724+
725+
```php
726+
'redis' => [
727+
'client' => 'phpredis',
728+
'options' => [
729+
'cluster' => 'redis',
730+
],
731+
'clusters' => [
732+
'default' => [
733+
[
734+
'host' => 'redis-cluster',
735+
'password' => null,
736+
'port' => 7000,
737+
'database' => 0,
738+
],
739+
],
740+
],
741+
],
742+
```
743+
744+
745+
746+
747+
748+
711749
<br>
712750
<a name="Use-Mongo"></a>
713751
## Use Mongo

docker-compose.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,14 @@ services:
456456
networks:
457457
- backend
458458

459+
### Redis Cluster ##########################################
460+
redis-cluster:
461+
build: ./redis-cluster
462+
ports:
463+
- "${REDIS_CLUSTER_PORT_RANGE}:7000-7005"
464+
networks:
465+
- backend
466+
459467
### ZooKeeper #########################################
460468
zookeeper:
461469
build: ./zookeeper

env-example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,10 @@ MYSQL_ENTRYPOINT_INITDB=./mysql/docker-entrypoint-initdb.d
220220

221221
REDIS_PORT=6379
222222

223+
### REDIS CLUSTER #########################################
224+
225+
REDIS_CLUSTER_PORT_RANGE=7000-7005
226+
223227
### ZooKeeper #############################################
224228

225229
ZOOKEEPER_PORT=2181

redis-cluster/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM grokzen/redis-cluster:latest
2+
3+
LABEL maintainer="hareku <hareku908@gmail.com>"

0 commit comments

Comments
 (0)