#### 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
~~~
- 歡迎使用swoolefy
- 環境說明
- 開發部署
- 安裝
- 創建應用
- 啟動|停止服務
- nginx代理
- 創建Controller
- 應用結構
- App應用對象
- Event請求處理
- 超全局管理
- 熱更新
- inotify實現worker進程熱重啟
- http服務
- 應用層配置
- 協議層配置
- 路由規則
- 控制器
- 數據模型
- websocket服務
- 應用層配置
- 協議層配置
- 數據封裝格式
- 控制器
- 數據模型
- 二進制數據處理
- rpc服務
- 應用層配置
- 協議程配置
- 數據包協議格式
- 服務控制器
- 服務數據模型
- udp服務
- 應用層配置
- 協議層配置
- 數據包封裝格式
- 控制器
- 存在問題
- 常用組件
- log
- view
- session
- cache(redis)
- db(mysql)
- mongodb
- 其他服務管理
- 自定義進程管理
- 異步任務管理
- 內存表管理
- 定時器管理
- 異常捕捉處理
- 進程池管理
- systerm采集進程服務