开始ping

@param mixed $redis
@return void
349003
private function startPing($redis)
    {
        if($this->ping($redis))
        {
            // 心跳定时器
            $this->timerID = \swoole_timer_tick($this->heartbeatTimespan * 1000, [$this, 'pingTimer']);
        }
    }
710241
def __connect():
    
    global redis_instance
    if use_tcp_socket:
        redis_instance = redis.StrictRedis(host=hostname, port=port)
    else:
        redis_instance = redis.StrictRedis(unix_socket_path=unix_socket)
1347269
public function ping($action = 'all', $operator = 'DEFAULT')
    {
        $url = 'https://api.weixin.qq.com/cgi-bin/callback/check?access_token=ACCESS_TOKEN';
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->callPostApi($url, ['action' => $action, 'check_operator' => $operator]);
    }
150867
public static function doRedirect($location) {
        if ( headers_sent() ) {
            // TODO: Check if this is fixed in PHP 70200
            // https://bugs.php.net/bug.php?id=74892
            if ( PHP_VERSION_ID >= 70000 ) {
                $location = U::addSession($location);
            }
            echo('<a href="'.$location.'">Continue</a>'."\n");
        } else {
            if ( ini_get('session.use_cookies') == 0 ) {
                $location = U::addSession($location);
            }
            header("Location: $location");
        }
    }
1305706
public function sendRedirect($location, $status = 302)
    {
        if (!is_int($status) || $status < 300 || $status > 399) {
            return;
        }
        
        if ($location[0] != '/' && !preg_match("/^[0-9a-z]+:\\/\\//i", $location)) {
            $location = $this->baseUrl . $location;
        }
        
        $this->clearHeaders();
        $this->addHeader('Location', $location, true);
        $this->setStatus($status);
        $this->isRedirect = true;
        $this->sendHeaders();
        
        exit();
    }
591157
public function onReady()
    {
        $this->redis = \PHPDaemon\Clients\Redis\Pool::getInstance();

        $params = [];
        foreach (range(0, 100) as $i) {
            $params[] = 'myset' . $i;
            $params[] = 'value' . $i;
        }
        $params[] = function ($redis) {
            $params = [
                function ($redis) {
                    D('Count: ' . count($redis->result[1]) . '; Next: ' . $redis->result[0]);
                }
            ];

            $cbEnd = function ($redis, $scan) {
                D('Full scan end!');
            };

            // test 1
            // $this->redis->scan(...$params);

            // test 2
            $this->redis->autoscan('scan', $params, $cbEnd, 50);
        };
        $this->redis->mset(...$params);
    }
1023323
public function reconnect($client = null)
    {
        go(function () use ($client) {
            if ($client->connect($this->config['redis'][$this->active]['ip'], $this->config['redis'][$this->active]['port']) == false) {
                throw new SwooleException($client->getLastError());
            }
            if (!empty($this->config->get('redis.' . $this->active . '.password', ""))) {//存在验证
                if ($client->auth($this->config['redis'][$this->active]['password']) == false) {
                    throw new SwooleException($client->getLastError());
                }
            }
            if ($this->config->has('redis.' . $this->active . '.select')) {//存在select
                $client->select($this->config['redis'][$this->active]['select']);
            }
            $this->pushToPool($client);
        });
    }
182412
public function setRedis(\Redis $redis)
    {
        $redis->setOption(Redis::OPT_SERIALIZER, $this->getSerializerValue());
        $this->_redis = $redis;
    }
1286231
protected function new_redis($server, $prefix = '', $password = '') {
        $redis = new Redis();
        $port = null;
        if (strpos($server, ':')) {
            $serverconf = explode(':', $server);
            $server = $serverconf[0];
            $port = $serverconf[1];
        }
        if ($redis->connect($server, $port)) {
            if (!empty($password)) {
                $redis->auth($password);
            }
            $redis->setOption(Redis::OPT_SERIALIZER, $this->serializer);
            if (!empty($prefix)) {
                $redis->setOption(Redis::OPT_PREFIX, $prefix);
            }
            // Database setting option...
            $this->isready = $this->ping($redis);
        } else {
            $this->isready = false;
        }
        return $redis;
    }
1029628
public function send($callback)
    {
        $this->arguments[] = $callback;
        $this->redisAsynPool->__call($this->name, $this->arguments);
    }
418046
public function ping($timeout = 1)
    {
        if ($socket = @fsockopen($this->protocol . '://' . $this->host, $this->port, $errCode, $errStr, $timeout)) {
            fclose($socket);

            return true;
        }

        return false;
    }
912515
public function ping() {

		if ( $this->getOption( ONOI_HTTP_REQUEST_URL ) === null ) {
			return false;
		}

		$urlComponents = $this->getUrlComponents( $this->getOption( ONOI_HTTP_REQUEST_URL ) );

		$resource = $this->getResourceFromSocketClient(
			$urlComponents,
			STREAM_CLIENT_CONNECT
		);

		if ( !$resource ) {
			return false;
		}

		stream_set_timeout( $resource, $this->getOption( ONOI_HTTP_REQUEST_CONNECTION_TIMEOUT ) );

		$httpMessage = (
			"HEAD "  . $urlComponents['path'] . " HTTP/1.1\r\n" .
			"Host: " . $urlComponents['host'] . "\r\n" .
			"Connection: Close\r\n\r\n"
		);

		$res = @fwrite( $resource, $httpMessage );

		if ( $this->getOption( ONOI_HTTP_REQUEST_FOLLOWLOCATION ) && $res !== false ) {
			$this->setOption( ONOI_HTTP_REQUEST_URL, $this->tryToFindFollowLocation( $resource, $urlComponents ) );
		}

		@fclose( $resource );

		return $res !== false;
	}
1241190
def ping():
    '''
    
    '''
    try:
        session, cookies, csrf_token = logon()
        logout(session, cookies, csrf_token)
    except salt.exceptions.CommandExecutionError:
        return False
    except Exception as err:
        log.debug(err)
        return False
    return True
1034709
public function working(Worker $worker)
    {
        $this->redis->sadd(self::redisKey(), $this->hostname);

        $this->redis->sadd(self::redisKey($this), (string)$worker);
        $this->redis->expire(self::redisKey($this), $this->timeout);
    }
115405
public function process_ping($data)
    {
        $ts = $data['timestamp'];

        return 'remote time: ' . date('c', $ts) . sprintf('.%03d', ($ts - (int)$ts) * 1000);
    }
141473
public function ping($uri) {
        $parsed_url = parse_url($uri);
        if (!$parsed_url || !is_array($parsed_url)) {
            return false;
        }
        
        $http = new \GuzzleHttp\Client(array('base_uri' => $parsed_url['host']));
        $res = $http->get($parsed_url['path'] . '?' . $parsed_url['query']);
        if ( 200 !== $res->getStatusCode()) {
            return false;
        }
        $content = $res->getBody();
        return true;
    }
602946
protected function connect()
    {
        if (!is_object(self::$instance)) {
            $func = $this->options['persistent'] ? 'pconnect' : 'connect';

            self::$instance = new \Redis();
            self::$instance->$func($this->options['host'], $this->options['port'], $this->options['timeout']);

            if ('' != $this->options['password']) {
                self::$instance->auth($this->options['password']);
            }
            if (0 != $this->options['select']) {
                self::$instance->select($this->options['select']);
            }
        }
    }