Enhancements to redis driver, such as enabling a serializer and/or compression
You can install the package via composer:
composer require vemcogroup/laravel-redisRemember to have redis installed with serializer and compression.
Answer yes to serializer and compression.
pecl upgrade -f redisIf you are missing igbinary
pecl install igbinaryIf you are missing libzstd
brew install zstdStart by selection the new driver vredis in you .env file:
REDIS_CLIENT=vredisCompression
To use compression you have to set the type in database.php for your redis connection:
'default' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_DB', '0'),
'options' => [
'compression' => Redis::COMPRESSION_NONE,
],
],You can use any of the Redis compressions available from you installation:
Redis::COMPRESSION_NONE, Redis::COMPRESSION_ZSTD, Redis::COMPRESSION_LZ4
Serializer
To use serialization you have to set the type in database.php for your redis connection:
'default' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_DB', '0'),
'options' => [
'serializer' => Redis::SERIALIZER_NONE,
],
],You can use any of the Redis serializers available from you installation:
Redis::SERIALIZER_NONE, Redis::SERIALIZER_PHP, Redis::SERIALIZER_IGBINARY, Redis::SERIALIZER_MSGPACK, Redis::SERIALIZER_JSON