首页 > 代码库 > yii2_文件缓存

yii2_文件缓存

1common\config\main.php

技术分享
‘components‘ => [ 
‘cache‘ => [ 
‘class‘ => ‘yii\caching\FileCache‘, 
‘cachePath‘ => ‘@runtime/cache2‘, 
], 
],
View Code

 

2用法

 

技术分享
1 $cache = Yii::$app->cache; 
2 $data = $cache->get(‘cache_data_key‘); 
3 if ($data === false) { 
4 $cache->set(‘cache_data_key‘, $cacheData, 60*60); 
5 } 
6 var_dump($data);
View Code

 

yii2_文件缓存