緩存
使用 `think\\Cache`
http://www.hmoore.net/manual/thinkphp6_0/1037634
緩存配置,在`config.ini.php`中。
~~~
/緩存 file 或 redis
$config['cache_drive'] = 'file';
//文件緩存前綴
$config['cache_prefix'] = 'domain_';
//redis緩存配置,僅當cache_drive為redis時有效
$config['cache_redis']['host'] = "127.0.0.1";
$config['cache_redis']['port'] = 6379;
//redis緩存前綴
$config['cache_redis']['prefix'] = '';
~~~
**緩存設置|獲取**
~~~
cache($key, $data = null, $second = null)
~~~
注冊 `$data` 可以為數組或者對象,將自動轉存為JSON,取值時JSON自動轉數組。
簡單說,`$data` 不要傳JSON數據。
**緩存刪除**
~~~
cache_delete($key)
~~~