diff --git a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php index a68995b05a9d..1c679fb60197 100644 --- a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php +++ b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php @@ -57,6 +57,7 @@ public function setUpRedis() 'port' => $port, 'database' => 5, 'timeout' => 0.5, + 'name' => 'default', ], ]); } diff --git a/src/Illuminate/Redis/Connectors/PhpRedisConnector.php b/src/Illuminate/Redis/Connectors/PhpRedisConnector.php index ba14ad87a928..090247feba18 100644 --- a/src/Illuminate/Redis/Connectors/PhpRedisConnector.php +++ b/src/Illuminate/Redis/Connectors/PhpRedisConnector.php @@ -102,6 +102,10 @@ protected function createClient(array $config) if (! empty($config['scan'])) { $client->setOption(Redis::OPT_SCAN, $config['scan']); } + + if (! empty($config['name'])) { + $client->client('SETNAME', $config['name']); + } }); } @@ -176,6 +180,10 @@ protected function createRedisClusterInstance(array $servers, array $options) if (! empty($options['failover'])) { $client->setOption(RedisCluster::OPT_SLAVE_FAILOVER, $options['failover']); } + + if (! empty($options['name'])) { + $client->client('SETNAME', $options['name']); + } }); } diff --git a/tests/Redis/RedisConnectorTest.php b/tests/Redis/RedisConnectorTest.php index 36b488582215..ff5f93470e8d 100644 --- a/tests/Redis/RedisConnectorTest.php +++ b/tests/Redis/RedisConnectorTest.php @@ -41,6 +41,7 @@ public function testDefaultConfiguration() $phpRedisClient = $this->redis['phpredis']->connection()->client(); $this->assertEquals($host, $phpRedisClient->getHost()); $this->assertEquals($port, $phpRedisClient->getPort()); + $this->assertEquals('default', $phpRedisClient->client('GETNAME')); } public function testUrl()