企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
[TOC] ### 组件说明 > Redis组件继承自\Reidis,而不是继承自Service,但是你同样可以在配置文件中配置它。 ### 配置选项 | 配置名 | 参数类型 | 可选 | 默认值 | 说明 | | --- | --- | --- | --- | --- | | class | string | 是 | lying\service\Redis | 可配置 | | host | string | 是 | 127.0.0.1 | redis主机 | | port | int | 是 | 6379 | redis端口 | | timeout | int | 是 | 0 | 连接超时时间 | | persistentId | string | 是 | null | 长连接ID,如果设置了此参数,讲使用redis长连接 | | password | string | 是 | '' | redis连接密码 | | select | int | 是 | 0 | redis使用的库 | | prefix | string | 是 | '' | redis前缀 | ### 示例配置 ~~~php 'redis' => [ 'class' => 'lying\service\Redis', 'host' => '127.0.0.1', //redis主机,默认127.0.0.1 'port' => 6379, //redis端口,默认6379 'timeout' => 0, //连接超时时间,默认0 'persistentId' => false,//长连接ID,如果设置了此参数,讲使用redis长连接,默认false 'password' => '', //redis连接密码,默认空 'select' => 0, //redis使用的库,默认0 'prefix' => 'lying', //redis前缀,默认空 ], ~~~ ### 调用方式 ~~~php \Lying::$maker->get('redis'); \Lying::$maker->redis('redisId'); \Lying::$maker->redis; ~~~ ### 方法列表 > 像使用原生\Redis一样来使用它 > 参见php-redis官方文档 [https://github.com/phpredis/phpredis](https://github.com/phpredis/phpredis)