1.宝塔安装swoole 扩展
2.tp6 配置 redis config/cache.php
return [
// 默认缓存驱动
'default' => env('cache.driver', 'redis'),
// 缓存连接方式配置
'stores' => [
'redis' => [
'host' => '127.0.0.1',
'port' => 6379,
'password' => '',
],
'file' => [
// 驱动方式
'type' => 'File',
// 缓存保存目录
'path' => '',
// 缓存前缀
'prefix' => '',
// 缓存有效期 0表示永久缓存
'expire' => 0,
// 缓存标签前缀
'tag_prefix' => 'tag:',
// 序列化机制 例如 ['serialize', 'unserialize']
'serialize' => [],
],
// 更多的缓存连接
],
];
3. 控制器里 使用
use think\facade\Cache;
//设置redis
Cache::store('redis')->set('test',123);
//获取reids
$test = Cache::store('redis')->get('test');
4.TP-Redis基础类库在
tp6shop\vendor\topthink\framework\src\think\cache\driver\Redis.php