Laravel - DejaVu
- Supports Multiple Sentinel, Slaves and Master
- Reading to slaves and writing to master if there is instance available it will send request to that instance
- Connection pooling by default, so there is no multiple TCP connection
- Master and Slave Auto Discovery and random traffic passing
This package requires minimum PHP 7.2 and Laravel 7.x version. And PHPRedis according to your PHP Version.
Installing PHP-Pear
apt install -y php-pearInstalling Redis Client
printf "no\n" | pecl install redisAdding Extension to php module
echo "extension=redis.so" > /etc/php/7.YOUR_PHP_VERSION/mods-available/redis.in
Symlinking with FPM and CLI
ln -sf /etc/php/7.YOUR_PHP_VERSION/mods-available/redis.ini /etc/php/7.YOUR_PHP_VERSION/fpm/conf.d/20-redis.ini
ln -sf /etc/php/7.YOUR_PHP_VERSION/mods-available/redis.ini /etc/php/7.YOUR_PHP_VERSION/cli/conf.d/20-redis.ini
Restarting PHP Service
systemctl restart php7.YOUR_PHP_VERSION-fpm.service
run this command from terminal:
composer require marufmax/dejavuAdd those to your .env file:
# Redis Configuration (Use comma Separated if have multiple)
REDIS_SENTINELS=localhost,localhost
REDIS_SENTINELS_PORTS=27379,27380
REDIS_PASS=AStrongPassword
Here there is two redis sentinels server. Please put only sentinel server not any master or slaves IPs. Due to redis sentinel limitation please set same password to every host. see https://github.com/bitnami/bitnami-docker-redis-sentinel/issues/23
Simply use DejaVu Facade instead of Cache Facade. Below is a very simple example
\MarufMax\DejaVu\Facades\DejaVu::put('hi', 'hello', 36);
dd(\MarufMax\DejaVu\Facades\DejaVu::get('hi'));Thanks 🐱