
使用的是5.19版本
/**配置代码**/
return [
'type' => 'complex',
// 默认使用的缓存
'default' => [
// 驱动方式
'type' => 'file',
// 缓存保存目录
'path' => '../runtime/default',
],
// redis缓存
'redis' => [
// 驱动方式
'type' => 'redis',
// 服务器地址
'host' => '127.0.0.1',
// 端口
'port' => '6379',
// 缓存保存目录
'path' => '../runtime/cache',
// 全局缓存有效期(0为永久有效)
'expire'=> 0,
],
];/**测试代码**/<?php
namespace app\index\controller;
use think\Cache;
class Index
{
public function test()
{
Cache::store('default')->set('name','value');
Cache::store('default')->get('name');
return 'test';
}
}tp5.02测试没问题,redis也能用,同样配置环境wamp集成,php7.2 最佳答案