/** * Returns the wrapped Redis client instance. * * This method is called from AbstractRedisWrapper, who uses it to call the desired method directly * on the wrapped redis, rather than using call_user_func(). * The command and key are passed into the method to allow for some logic within the implementations * of this method. * * @param string $command the current command * @param string|null $key the current key if available, null otherwise. Commands that operate on * multiple keys will pass their keys as a comma separated string. * @throws Exception when an error happens during connecting * @return Redis */ protected function getWrappedRedis($command, $key = null) { // if we don't have a client yet, we never connected, so let's do it now if (!$this->client) { // gotta make sure the app actually tried to connect first if (!$this->connectWasCalled) { throw new Exception('call connect() or pconnect() first'); } if (!($this->persistent ? $this->conn->pconnect($this->host, $this->port, $this->timeout) : $this->conn->connect($this->host, $this->port, $this->timeout))) { throw new Exception('could not connect to ' . $this->conn->getUniqueId() . ' params: ' . (!empty($this->host) ? $this->host . ':' . $this->port : 'none')); } $this->client = $this->conn->getClient(); } return $this->client; }
/** * @param Connection $connection The connection to wrap * @param string $logFile The name of the file to log the commands to * @param \Psr\Log\LoggerInterface $log */ public function __construct(Connection $connection, $logFile, LoggerInterface $log = null) { $this->connection = $connection; $this->client = $connection->getClient(); $this->logFile = $logFile; if ($log === null) { $log = new NullLog(); } $this->log = $log; }
/** * @param Connection $connection The connection to catch exceptions for * @param ExceptionHandler $handler The error handler which is called if any exception happens * @param LoggerInterface $log The logger to which all the exceptions are logged */ function __construct(Connection $connection, ExceptionHandler $handler = null, LoggerInterface $log = null) { $this->connection = $connection; $this->client = $connection->getClient(); $this->exceptionHandler = $handler; $this->defaultHandlerStrategy = ExceptionStrategy::DISCARD(); if ($log === null) { $log = new NullLog(); } $this->log = $log; }
/** * @param Connection $connection */ public function __construct(Connection $connection) { $this->connection = $connection; $this->redis = $connection->getClient(); }
/** * @param Connection $conn the wrapped redis connection * @param Logger $logger optional, a logger to log the invalid calls to */ public function __construct(Connection $conn, LoggerInterface $logger = null) { $this->conn = $conn; $this->redis = $conn->getClient(); $this->logger = $logger; }
public function __construct(Connection $conn, Time $time = null) { $this->connection = $conn; $this->redis = $this->connection->getClient(); $this->time = $time ?: new SystemTime(); }
/** * @param Connection $conn Connection of the wrapped instance */ public function __construct(Connection $conn) { $this->connection = $conn; $this->client = $conn->getClient(); }
/** * Test getting the redis interface implementation */ public function testGetClient() { $this->assertInstanceOf(Redis::class, $this->redis->getClient()); }