## 遇到的問題
1、生產環境大量使用了redis作為緩存驅動,本地開發環境不支持redis。如jwt驗證等。
## 解決方案
1、我們在線上引入了Yaconf來對配置進行管理,將Redis信息寫進Yaconf管理的配置文件,然后在TP的cache配置中,使用以下代碼來完成
```
$config=[
'type' => 'complex',
'default' => [
'type' => 'file',
// 全局緩存有效期(0為永久有效)
'expire'=> 0,
// 緩存前綴
'prefix'=> 'think',
// 緩存目錄
'path' => '../runtime/cache/',
],
'redis' => [
'type' => 'file',
// 全局緩存有效期(0為永久有效)
'expire'=> 0,
// 緩存前綴
'prefix'=> 'think',
// 緩存目錄
'path' => '../runtime/cache/',
],
];
return class_exists(\Yaconf::class)?\Yaconf::get('test.cache'):$config;
```
這樣在本地,使用`Cache::store('redis')`使用的是文件驅動,線上使用的redis驅動。
同樣,其他的一些沖突也是用此類方法解決。