/** * @param array $server * @throws InvalidConfigException */ public function setServer($server) { if (!$server instanceof RedisServer) { $server = RedisServer::create($server); } if (null !== $server->unixSocket) { $result = $this->getRedis()->connect($server->unixSocket); } else { $result = $this->getRedis()->connect($server->host, $server->port, $server->timeout); } if (!$result) { throw new InvalidConfigException(__CLASS__ . ' unable to connect to redis server.'); } $this->getRedis()->select($server->dbIndex); }
public function testCreateUnixSocket() { $server = RedisServer::create(['unixSocket' => '/tmp/redis.sock']); $this->assertInstanceOf('\\Hitmeister\\Component\\RapidoCache\\Server\\RedisServer', $server); $this->assertEquals('/tmp/redis.sock', $server->unixSocket); }