Skip to content

Commit

Permalink
[8.x] Make it possible to use prefixes on Predis per Connection (#40083)
Browse files Browse the repository at this point in the history
* Make it possible to set prefix per connection

* Fix formatting

* Add new code to connect to cluster as well

* Use isset instead of empty

To allow the use of zero. Change the function from empty to isset
  • Loading branch information
tben authored Dec 17, 2021
1 parent 51e358c commit 33fb408
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Illuminate/Redis/Connectors/PredisConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ public function connect(array $config, array $options)
['timeout' => 10.0], $options, Arr::pull($config, 'options', [])
);

if (isset($config['prefix'])) {
$formattedOptions['prefix'] = $config['prefix'];
}

return new PredisConnection(new Client($config, $formattedOptions));
}

Expand All @@ -38,6 +42,10 @@ public function connectToCluster(array $config, array $clusterOptions, array $op
{
$clusterSpecificOptions = Arr::pull($config, 'options', []);

if (isset($config['prefix'])) {
$clusterSpecificOptions['prefix'] = $config['prefix'];
}

return new PredisClusterConnection(new Client(array_values($config), array_merge(
$options, $clusterOptions, $clusterSpecificOptions
)));
Expand Down

0 comments on commit 33fb408

Please sign in to comment.