本文整理汇总了PHP中resource::ping方法的典型用法代码示例。如果您正苦于以下问题:PHP resource::ping方法的具体用法?PHP resource::ping怎么用?PHP resource::ping使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类resource
的用法示例。
在下文中一共展示了resource::ping方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: close
/**
* Close
*
* Releases locks and closes connection.
*
* @return bool
*/
public function close()
{
if (isset($this->_redis)) {
try {
if ($this->_redis->ping() === '+PONG') {
isset($this->_lock_key) && $this->_redis->delete($this->_lock_key);
if (!$this->_redis->close()) {
return FALSE;
}
}
} catch (RedisException $e) {
}
$this->_redis = NULL;
return TRUE;
}
return TRUE;
}
示例2: close
/**
* Close
*
* Releases locks and closes connection.
*
* @return bool
*/
public function close()
{
if (isset($this->_redis)) {
try {
if ($this->_redis->ping() === '+PONG') {
isset($this->_lock_key) && $this->_redis->delete($this->_lock_key);
if (!$this->_redis->close()) {
return $this->_failure;
}
}
} catch (RedisException $e) {
log_message('error', 'Session: Got RedisException on close(): ' . $e->getMessage());
}
$this->_redis = NULL;
return $this->_success;
}
return $this->_success;
}
示例3: close
/**
* Close
*
* Releases locks and closes connection.
*
* @return bool
*/
public function close()
{
if (isset($this->_redis)) {
try {
if ($this->_redis->ping() === '+PONG') {
$this->_release_lock();
if ($this->_redis->close() === FALSE) {
return $this->_fail();
}
}
} catch (RedisException $e) {
log_message('error', 'Session: Got RedisException on close(): ' . $e->getMessage());
}
$this->_redis = NULL;
return $this->_success;
}
return $this->_success;
}
示例4: close
/**
* Close
*
* Releases locks and closes connection.
*
* @return bool
*/
public function close()
{
if (isset($this->redis)) {
try {
if ($this->redis->ping() === '+PONG') {
isset($this->lockKey) && $this->redis->delete($this->lockKey);
if (!$this->redis->close()) {
return FALSE;
}
}
} catch (\RedisException $e) {
$this->logger->error('Session: Got RedisException on close(): ' . $e->getMessage());
}
$this->redis = NULL;
return TRUE;
}
return TRUE;
}
示例5: __call
//.........这里部分代码省略.........
$args = array($args[0], array_merge($cKeys, $cArgs), count($cKeys));
break;
case 'subscribe':
case 'psubscribe':
break;
case 'scan':
case 'sscan':
case 'hscan':
case 'zscan':
// allow phpredis to see the caller's reference
//$param_ref =& $args[0];
break;
default:
// Flatten arguments
$args = self::_flattenArguments($args);
}
try {
// Proxy pipeline mode to the phpredis library
if ($name == 'pipeline' || $name == 'multi') {
if ($this->isMulti) {
return $this;
} else {
$this->isMulti = TRUE;
$this->redisMulti = call_user_func_array(array($this->redis, $name), $args);
}
} else {
if ($name == 'exec' || $name == 'discard') {
$this->isMulti = FALSE;
$response = $this->redisMulti->{$name}();
$this->redisMulti = NULL;
#echo "> $name : ".substr(print_r($response, TRUE),0,100)."\n";
return $response;
}
}
// Use aliases to be compatible with phpredis wrapper
if (isset($this->wrapperMethods[$name])) {
$name = $this->wrapperMethods[$name];
}
// Multi and pipeline return self for chaining
if ($this->isMulti) {
call_user_func_array(array($this->redisMulti, $name), $args);
return $this;
}
// Send request, retry one time when using persistent connections on the first request only
$this->requests++;
try {
$response = call_user_func_array(array($this->redis, $name), $args);
} catch (RedisException $e) {
if ($this->persistent && $this->requests == 1 && $e->getMessage() == 'read error on connection') {
$this->connected = FALSE;
$this->connect();
$response = call_user_func_array(array($this->redis, $name), $args);
} else {
throw $e;
}
}
} catch (RedisException $e) {
$code = 0;
if (!($result = $this->redis->ping())) {
$this->connected = FALSE;
$code = CredisException::CODE_DISCONNECTED;
}
throw new CredisException($e->getMessage(), $code, $e);
}
#echo "> $name : ".substr(print_r($response, TRUE),0,100)."\n";
// change return values where it is too difficult to minim in standalone mode
switch ($name) {
case 'hmget':
$response = array_values($response);
break;
case 'type':
$typeMap = array(self::TYPE_NONE, self::TYPE_STRING, self::TYPE_SET, self::TYPE_LIST, self::TYPE_ZSET, self::TYPE_HASH);
$response = $typeMap[$response];
break;
// Handle scripting errors
// Handle scripting errors
case 'eval':
case 'evalsha':
case 'script':
$error = $this->redis->getLastError();
$this->redis->clearLastError();
if ($error && substr($error, 0, 8) == 'NOSCRIPT') {
$response = NULL;
} else {
if ($error) {
throw new CredisException($error);
}
}
break;
default:
$error = $this->redis->getLastError();
$this->redis->clearLastError();
if ($error) {
throw new CredisException($error);
}
break;
}
}
return $response;
}