本文整理汇总了PHP中Predis\Client::disconnect方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::disconnect方法的具体用法?PHP Client::disconnect怎么用?PHP Client::disconnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Predis\Client
的用法示例。
在下文中一共展示了Client::disconnect方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: clear_redis_cache
/**
* Flush all keys in Redis
*/
public function clear_redis_cache()
{
$redis_host = config('database.redis.default.host');
$redis_port = config('database.redis.default.port');
$this->info('Clearing the Redis Cache at: ' . $redis_host . ':' . $redis_port);
try {
$redis = new Client(['host' => $redis_host, 'port' => $redis_port]);
$redis->flushall();
$redis->disconnect();
} catch (Exception $e) {
$this->error('Failed to clear the Redis Cache. Error: ' . $e->getMessage());
}
return;
}
示例2: disconnect
/**
* @inheritdoc
*/
public function disconnect()
{
if (!$this->isConnected()) {
return;
}
$this->client->disconnect();
$this->client = null;
}
示例3: fork
public function fork()
{
$id = pcntl_fork();
if (!$id) {
$this->redis->disconnect();
$this->redis->connect();
}
return $id;
}
示例4: __destruct
/**
* Properly close the connection.
*
* {@inheritdoc}
*/
public function __destruct()
{
if ($this->redis instanceof \Predis\Client) {
try {
$this->redis->disconnect();
} catch (\ConnectionException $e) {
/*
* \Predis\Client::disconnect will throw a \ConnectionException("Redis server went away") exception if
* we haven't previously been able to connect to Redis or the connection has severed.
*/
}
}
}
示例5: Cleanup
public function Cleanup()
{
$this->status = 'offline';
$this->Report();
$this->redis->disconnect();
unset($this->beanstalk);
unset($this->redis);
}
示例6: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$client = new Client();
try {
$client->connect();
$client->disconnect();
self::$supported = true;
} catch (ConnectionException $e) {
self::$supported = false;
}
}
示例7: testConnectAndDisconnect
/**
* @group disconnected
*/
public function testConnectAndDisconnect()
{
$connection = $this->getMock('Predis\\Connection\\ConnectionInterface');
$connection->expects($this->once())->method('connect');
$connection->expects($this->once())->method('disconnect');
$client = new Client($connection);
$client->connect();
$client->disconnect();
}
示例8: __destruct
public function __destruct()
{
$this->predis->disconnect();
}
示例9: testPubSubAgainstRedisServerBlocking
/**
* @group connected
* @requires extension pcntl
*/
public function testPubSubAgainstRedisServerBlocking()
{
$parameters = array('host' => REDIS_SERVER_HOST, 'port' => REDIS_SERVER_PORT, 'database' => REDIS_SERVER_DBNUM, 'read_write_timeout' => -1);
$options = array('profile' => REDIS_SERVER_VERSION);
// create consumer before forking so the child can disconnect it
$consumer = new Client($parameters, $options);
$consumer->connect();
/*
* fork
* parent: consumer
* child: producer
*/
if ($childPID = pcntl_fork()) {
$messages = array();
$pubsub = new PubSubConsumer($consumer);
$pubsub->subscribe('channel:foo');
foreach ($pubsub as $message) {
if ($message->kind !== 'message') {
continue;
}
$messages[] = $payload = $message->payload;
if ($payload === 'QUIT') {
$pubsub->stop();
}
}
$this->assertSame(array('message1', 'message2', 'QUIT'), $messages);
$this->assertFalse($pubsub->valid());
$this->assertEquals('ECHO', $consumer->echo('ECHO'));
// kill the child
posix_kill($childPID, SIGKILL);
} else {
// create producer, read_write_timeout = 2 because it doesn't do blocking reads anyway
$producer = new Client(array_replace($parameters, array('read_write_timeout' => 2)), $options);
$producer->connect();
$producer->publish('channel:foo', 'message1');
$producer->publish('channel:foo', 'message2');
$producer->publish('channel:foo', 'QUIT');
// sleep, giving the consumer a chance to respond to the QUIT message
sleep(1);
// disconnect the consumer because otherwise it could remain stuck in blocking read
// if it failed to respond to the QUIT message
$consumer->disconnect();
// exit child
exit(0);
}
}
示例10: disconnect
public function disconnect()
{
$this->_client->disconnect();
}
示例11: __destruct
public function __destruct()
{
$this->client->disconnect();
}