class Predis in Redis 8
Same name in this branch
- 8 src/Lock/Predis.php \Drupal\redis\Lock\Predis
- 8 src/Flood/Predis.php \Drupal\redis\Flood\Predis
- 8 src/Queue/Predis.php \Drupal\redis\Queue\Predis
- 8 src/Client/Predis.php \Drupal\redis\Client\Predis
- 8 src/Cache/Predis.php \Drupal\redis\Cache\Predis
- 8 src/PersistentLock/Predis.php \Drupal\redis\PersistentLock\Predis
Predis client specific implementation.
Hierarchy
- class \Drupal\redis\Client\Predis implements ClientInterface
Expanded class hierarchy of Predis
3 string references to 'Predis'
- ClientFactory::getClientInterface in src/
ClientFactory.php - Lazy instantiates client proxy depending on the actual configuration.
- Predis::getName in src/
Client/ Predis.php - Get underlying library name used.
- RedisCacheTagsChecksum::doInvalidateTags in src/
Cache/ RedisCacheTagsChecksum.php - Marks cache items with any of the specified tags as invalid.
File
- src/
Client/ Predis.php, line 12
Namespace
Drupal\redis\ClientView source
class Predis implements ClientInterface {
public function getClient($host = NULL, $port = NULL, $base = NULL, $password = NULL, $replicationHosts = [], $persistent = FALSE) {
$connectionInfo = [
'password' => $password,
'host' => $host,
'port' => $port,
'database' => $base,
'persistent' => $persistent,
];
foreach ($connectionInfo as $key => $value) {
if (!isset($value)) {
unset($connectionInfo[$key]);
}
}
// I'm not sure why but the error handler is driven crazy if timezone
// is not set at this point.
// Hopefully Drupal will restore the right one this once the current
// account has logged in.
date_default_timezone_set(@date_default_timezone_get());
// If we are passed in an array of $replicationHosts, we should attempt a clustered client connection.
if (!empty($replicationHosts)) {
$parameters = [];
foreach ($replicationHosts as $replicationHost) {
$param = 'tcp://' . $replicationHost['host'] . ':' . $replicationHost['port'] . '?persistent=' . ($persistent ? 'true' : 'false');
// Configure master.
if ($replicationHost['role'] === 'primary') {
$param .= '&alias=master';
}
$parameters[] = $param;
}
$options = [
'replication' => true,
];
$client = new Client($parameters, $options);
}
else {
$client = new Client($connectionInfo);
}
return $client;
}
public function getName() {
return 'Predis';
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Predis:: |
public | function |
Get the connected client instance. Overrides ClientInterface:: |
|
Predis:: |
public | function |
Get underlying library name used. Overrides ClientInterface:: |