cache配置,文件位置:config/cache.php
<?php // +---------------------------------------------------------------------- // | 緩存設置 // +---------------------------------------------------------------------- return [ // 默認緩存驅動 'default' => env('cache.driver', 'file'), // 緩存連接方式配置 'stores' => [ 'file' => [ // 驅動方式 'type' => 'File', // 緩存保存目錄 'path' => '', // 緩存前綴 'prefix' => '', // 緩存有效期 0表示永久緩存 'expire' => 0, // 緩存標簽前綴 'tag_prefix' => 'tag:', // 序列化機制 例如 ['serialize', 'unserialize'] 'serialize' => [], ], // 配置Reids 'redis' => [ 'type' => 'redis', 'host' => '127.0.0.1', 'port' => '6379', 'password' => '123456', 'select' => '0', // 全局緩存有效期(0為永久有效) 'expire' => 0, // 緩存前綴 'prefix' => '', 'timeout' => 0, ], ], ];
控制器調用:
use think\facade\Cache; public function test(){ Cache::store('redis')->set('name','value',3600); }
************************************************
Thinkphp高級交QQ流群:101766150
作者:狂奔的蝸牛
轉載請注明出處
************************************************