多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
# swoole/redis 此组件由swoole底层提供,由C语言编写,具有超高性能。 ## 安装: ```php 安装有swoole扩展即可 ``` ## 示例: ```php <?php /** * 编译swoole时,在configure指令中加入--enable-async-redis */ require_once '../Autoloader.php'; use Workerman\Worker; use Swoole\Redis; $worker = new Worker('tcp://0.0.0.0:6161'); $worker->onWorkerStart = function () { global $client; $client = new Redis; $client->connect('127.0.0.1', 6379, function (Redis $client, $result) { echo "connect\n"; var_dump($result); $db = 0; $client->select($db); $password = '111111'; $client->auth($password); }); }; $worker->onMessage = function ($connection, $data) { global $client; $client->set('key', 'swoole', function (Redis $client, $result) { var_dump($result); $client->get('key', function (Redis $client, $result) { var_dump($result); $client->close(); }); }); }; Worker::runAll(); ``` ## 文档: <https://wiki.swoole.com/wiki/page/p-redis.html>