https://wiki.swoole.com/wiki/page/576.html
协程redis 同步代码实现异步IO的操作
<?php /** * Created by PhpStorm. * User: whitneywang * Date: 2018/6/4 * Time: 16:10 */ $http = new swoole_http_server('0.0.0.0', 9503); $http->on('request', function ($request, $response) { //协程redis 同步代码实现异步IO的操作 $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();
程序最大运行时间 就是MYSQL和redis最大时间,比如redis1秒,mysql2秒,最终时间是2秒
传统是1+2=3秒
所以性能提升,那是相当可以