企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
#### cache缓存 cache缓存是基于predis组件实现的,要使用cache,如果没有安装,必须安装predis组件 ~~~ composer require predis/predis ~~~ * 配置 ~~~ components => [ // 第一种配置方式 'redis' =>[ 'class' => 'Swoolefy\Core\Cache\Redis', 'constructor'=> [ [ 'scheme' => 'tcp', 'host' => '192.168.99.102', 'port' => 6379, 'password' => '123456' ], ] ], // 第二种动态原生创建,更加灵活,推荐 'redis'=>function($com_name) { $parameters = [ 'scheme' => 'tcp', 'host' => '192.168.99.102', 'port' => 6379, 'password' => '123456' ], $optinons = []; $redis = new Swoolefy\Core\Cache\Redis($parameters, $options); return $redis; } ] ~~~ constructor:这个选项的配置值其实与predis创建client的实例要设置的配置值是一致的,具体的参考[https://github.com/nrk/predis](https://github.com/nrk/predis) ~~~ $client = new Predis\Client( [ 'scheme' => 'tcp', 'host' => '10.0.0.1', 'port' => 6379, 'password' => '123456' ] ); ~~~ #### 二、swoole的异步redis支持 1、依赖于hiredis(swoole 4.2.16+不需要安装,以内置) https://github.com/redis/hiredis/tree/v0.13.3 ~~~ make -j sudo make install sudo ldconfig ~~~ 2、直接安装swoole的./configure --enable-async-redis,一般会报错说找不到hiredis.h,那么我们进去hiredis文件需要将编译好的把libhiredis.so放到/usr/local/lib/中,把hiredis.h放到/usr/local/inlcude/hiredis/中的。 3、重新执行 ~~~ ./configure --enable-async-redis make clean make make install ~~~