CacheController.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2018/2/26/026
  6. * Time: 9:56
  7. */
  8. namespace backend\controllers;
  9. use backend\base\CommonController;
  10. use backend\base\Help;
  11. use Yii;
  12. class CacheController extends CommonController
  13. {
  14. // public $enableCsrfValidation = false;
  15. //2
  16. //3
  17. /*
  18. * 缓存清理页面 - 静态资源
  19. * */
  20. public function actionRes()
  21. {
  22. return $this->render('res');
  23. }
  24. /*
  25. * 静态资源缓存清理
  26. * */
  27. public function actionStaticcacheclear()
  28. {
  29. $cache = Yii::$app->cache;
  30. switch (Yii::$app->request->post('type')){
  31. case 1:
  32. $name = Yii::$app->params['resourceCacheKey']['mobile'];
  33. break;
  34. case 2:
  35. $name = Yii::$app->params['resourceCacheKey']['frontend'];
  36. break;
  37. case 3:
  38. $name = Yii::$app->params['resourceCacheKey']['backend'];
  39. break;
  40. default:
  41. return Help::JsonCode(Help::ERROR,Yii::t('app','edit_error'));
  42. }
  43. if($cache->set($name,time()))
  44. {
  45. return Help::JsonCode(Help::SUCCESS,Yii::t('app','edit_success'));
  46. }
  47. return Help::JsonCode(Help::ERROR,Yii::t('app','edit_error'));
  48. }
  49. }