From 382f6144fc9c9ba75d1bc1ef496269ce961bb8e4 Mon Sep 17 00:00:00 2001 From: Gilbert Paquin Date: Tue, 25 Mar 2025 22:03:53 -0400 Subject: [PATCH 1/2] Update redis, add Unix socket instructions Add Unix socket configuration instructions for Redis --- redis.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/redis.md b/redis.md index 9815700778e..6d24a3a2f5f 100644 --- a/redis.md +++ b/redis.md @@ -210,6 +210,37 @@ In addition to the default configuration options, PhpRedis supports the followin ], ``` +### Unix Socket Connections + +Redis connections can also be configured to use Unix sockets instead of TCP. This can offer improved performance by eliminating TCP overhead for connections on the same server. + +To configure Redis to use a Unix socket with Laravel and the PhpRedis extension, you must set the `host` parameter to the path of the Redis socket and the `port` to `0`. + +Here's how you can set this in your `.env` file: + +```env +REDIS_HOST=/run/redis/redis.sock +REDIS_PORT=0 +``` + +Update your Laravel Redis configuration accordingly in the `config/database.php` file: + +```php +'redis' => [ + 'client' => env('REDIS_CLIENT', 'phpredis'), + + 'default' => [ + 'scheme' => 'unix', + 'host' => env('REDIS_HOST', '/run/redis/redis.sock'), + 'port' => env('REDIS_PORT', 0), + 'database' => env('REDIS_DB', '0'), + ], +], +``` + +When configured correctly, Laravel will seamlessly use the Unix socket for Redis connections, leveraging the performance benefits provided by local socket communication. + + #### PhpRedis Serialization and Compression From b6fcc69d8a2a3168dd415ab231270e11dc7990f5 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 4 Apr 2025 09:31:15 -0500 Subject: [PATCH 2/2] Update redis.md --- redis.md | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/redis.md b/redis.md index 6d24a3a2f5f..1991d667673 100644 --- a/redis.md +++ b/redis.md @@ -210,37 +210,16 @@ In addition to the default configuration options, PhpRedis supports the followin ], ``` -### Unix Socket Connections + +#### Unix Socket Connections -Redis connections can also be configured to use Unix sockets instead of TCP. This can offer improved performance by eliminating TCP overhead for connections on the same server. - -To configure Redis to use a Unix socket with Laravel and the PhpRedis extension, you must set the `host` parameter to the path of the Redis socket and the `port` to `0`. - -Here's how you can set this in your `.env` file: +Redis connections can also be configured to use Unix sockets instead of TCP. This can offer improved performance by eliminating TCP overhead for connections to Redis instances on the same server as your application. To configure Redis to use a Unix socket, set your `REDIS_HOST` environment variable to the path of the Redis socket and the `REDIS_PORT` environment variable to `0`: ```env REDIS_HOST=/run/redis/redis.sock REDIS_PORT=0 ``` -Update your Laravel Redis configuration accordingly in the `config/database.php` file: - -```php -'redis' => [ - 'client' => env('REDIS_CLIENT', 'phpredis'), - - 'default' => [ - 'scheme' => 'unix', - 'host' => env('REDIS_HOST', '/run/redis/redis.sock'), - 'port' => env('REDIS_PORT', 0), - 'database' => env('REDIS_DB', '0'), - ], -], -``` - -When configured correctly, Laravel will seamlessly use the Unix socket for Redis connections, leveraging the performance benefits provided by local socket communication. - - #### PhpRedis Serialization and Compression