## Thinkphp中使用Redis
**Thinkphp5**
cache.php 配置
```
return [
// 緩存配置為復合類型
'type' => 'complex',
'default' => [
'type' => 'file',
// 全局緩存有效期(0為永久有效)
'expire'=> 0,
// 緩存前綴
'prefix'=> 'think',
// 緩存目錄
'path' => '../runtime/cache/',
],
'redis' => [
'type' => 'redis',
'host' => '127.0.0.1',
// 全局緩存有效期(0為永久有效)
'expire'=> 0,
// 緩存前綴
'prefix'=> 'think',
],
// 添加更多的緩存類型設置
];
```
**使用Redis緩存**
~~~
Cache::store('redis')->set('name','value',3600);
Cache::store('redis')->get('name');
~~~
如果要返回當前緩存類型對象的句柄,可以使用
~~~
// 獲取Redis對象 進行額外方法調用
Cache::store('redis')->handler();
~~~