1. 程式人生 > >【thinkphp5+swoole賽事直播教程系列18】協程

【thinkphp5+swoole賽事直播教程系列18】協程

<?php


$http = new swoole_http_server('0.0.0.0', 8001);

$http->on('request', function($request, $response) {
    // 獲取redis 裡面 的key的內容, 然後輸出瀏覽器

    $redis = new Swoole\Coroutine\Redis();
    $redis->connect('127.0.0.1', 6379);
    $value = $redis->get($request->get['a']);

    $response->header("Content-Type", "text/plain");
    $response->end($value);
});

$http->start();