官方文档就缓存的配置如下:
$options = [ // 缓存类型为File 'type' => 'File', // 缓存有效期为永久有效 'expire'=> 0, //缓存前缀 'prefix'=> 'think', // 指定缓存目录 'path' => APP_PATH.'runtime/cache/', ]; Cache::connect($options);
看着让人不明所以,也不知道在哪配置,经过研究,
应在application文件夹下的config.php里,
找到如下缓存设置,将原有的缓存配置(下面注释的部分)改成如下未注释,就好了。
// +---------------------------------------------------------------------- // | 缓存设置 // +---------------------------------------------------------------------- // 原本配置方式,存入本地文件缓存 /*'cache'=> [ // 驱动方式 'type' => 'File', // 缓存保存目录 'path' => CACHE_PATH, // 缓存前缀 'prefix' => '', // 缓存有效期 0表示永久缓存 'expire' => 0, ],*/ //redis 缓存设置 'cache'=> [ // 驱动方式 'type' => 'Redis', 'host' => '127.0.0.1', 'port' => '6379', 'password' => '', 'timeout'=> 20//过期时间,做测试可将时间设的短一些 ],