ソースを参照

wesmiler 报恩寺项目提交

wesmiler 4 年 前
コミット
518edf0002

+ 0 - 1
app/Http/Controllers/Api/AuthController.php

@@ -63,7 +63,6 @@ class AuthController extends BaseController
         ];
 
         // 用户信息
-        RedisService::set("auths:request:$userId", request()->all(), 600);
         RedisService::set("auths:info:{$userId}", $this->userInfo, 4*24*3600);
         return message('获取授权成功', true, $result);
     }

+ 12 - 0
app/Http/Controllers/IndexController.php

@@ -15,6 +15,7 @@ use App\Models\UserModel;
 use App\Models\AdminRomModel;
 use App\Services\AdminService;
 use App\Services\MenuService;
+use App\Services\RedisService;
 use App\Services\UserService;
 
 /**
@@ -89,4 +90,15 @@ class IndexController extends Backend
         return $result;
     }
 
+    /**
+     * 清除缓存
+     * @return array
+     */
+    public function clearCache(){
+        RedisService::keyDel("caches:config:*");
+        RedisService::keyDel("caches:index:*");
+        RedisService::keyDel("caches:articles:*");
+        RedisService::keyDel("caches:qrcodes:*");
+        return message(MESSAGE_OK, true);
+    }
 }

+ 2 - 2
app/Services/AdService.php

@@ -68,7 +68,7 @@ class AdService extends BaseService
     public function geListBySort($sortId, $num=6){
         $showNum = ConfigService::make()->getConfigByCode("index_ad_{$sortId}_num");
         $num = $showNum? $showNum : $num;
-        $cacheKey = "caches:adverts:list_sort_{$sortId}_{$num}";
+        $cacheKey = "caches:index:adverts:list_sort_{$sortId}_{$num}";
         $dataList = RedisService::get($cacheKey);
         if($dataList){
             return $dataList;
@@ -102,7 +102,7 @@ class AdService extends BaseService
      * @return array|mixed
      */
     public function geDataBySort($sortId){
-        $cacheKey = "caches:adverts:data_sort_{$sortId}";
+        $cacheKey = "caches:index:adverts:data_sort_{$sortId}";
         $data = RedisService::get($cacheKey);
         if($data){
             return $data;

+ 1 - 0
routes/web.php

@@ -74,6 +74,7 @@ Route::get('/index/getMenuList', [IndexController::class, 'getMenuList']);
 Route::get('/index/getUserInfo', [IndexController::class, 'getUserInfo']);
 Route::post('/index/updateUserInfo', [IndexController::class, 'updateUserInfo']);
 Route::post('/index/updatePwd', [IndexController::class, 'updatePwd']);
+Route::post('/index/clearCache', [IndexController::class, 'clearCache']);
 
 // 用户管理
 Route::get('/user/index', [UserController::class, 'index']);