webjjel/laravel-read-write-redis

Using Read/Write Redis connection for Laravel

0.1.0 2019-10-16 09:12 UTC

This package is auto-updated.

Last update: 2024-05-16 20:22:50 UTC


README

Packagist License Latest Stable Version Total Downloads

The webjjel/laravel-read-write-redis package provides read/write connection for redis.

Installation

PHP 7.1 and Laravel 5.8 or higher are required.

You can install the package via composer:

composer require webjjel/laravel-read-write-redis

The package will automatically register itself.

Usage

You have to set the read/write connection in config/database.php

'redis' => [
    'write' => [
        'host'     => env('REDIS_WRITE_HOST', '127.0.0.1'),
        'password' => env('REDIS_WRITE_PASSWORD', null),
        'port'     => env('REDIS_WRITE_PORT', 6379),
        'database' => 0,
    ],

    'read' => [
        'host'     => env('REDIS_READ_HOST', '127.0.0.1'),
        'password' => env('REDIS_READ_PASSWORD', null),
        'port'     => env('REDIS_READ_PORT', 6379),
        'database' => 0,
    ],
],

and then set the redis connection in config/cache.php

'stores' => [
    'redis-read-write' => [
        'driver' => 'redis-read-write',
        // If you want to change connection name, edit below configuration.
        // 'connection' => [
        //     'write' => 'write',
        //     'read'  => 'read',
        // ],
    ],
]

If you want to use read/write redis cache by default, You can change environment in .env

CACHE_DRIVER=redis-read-write

License

The MIT License (MIT). Please see License File for more information.