Przeglądaj źródła

所有cache存储全部改为Redis存储

durong 5 lat temu
rodzic
commit
dacaa34206

+ 8 - 4
app/Repositories/CmsContentTemplateRepository.php

@@ -8,6 +8,7 @@ use App\Models\CmsContentTemplateSet;
 use Illuminate\Support\Facades\Cache;
 use Illuminate\Support\Facades\Log;
 use Symfony\Component\HttpKernel\Exception\HttpException;
+use Illuminate\Support\Facades\Redis;
 
 class CmsContentTemplateRepository {
     public function __construct(CmsContentTemplate $cmsContentTemplate) {
@@ -108,12 +109,15 @@ class CmsContentTemplateRepository {
             throw new HttpException(500, '修改状态失败');
         }
         if ($template_id->apply_type == 0){
-            if (Cache::has($group_key)) {
-                Cache::forget($group_key);
+//            if (Cache::has($group_key)) {
+//                Cache::forget($group_key);
+//            }
+            if (Redis::exists($group_key)) {
+                Redis::del($group_key);
             }
         }elseif ($template_id->apply_type == 1){
-            if (Cache::has($market_key)) {
-                Cache::forget($market_key);
+            if (Redis::exists($market_key)) {
+                Redis::del($market_key);
             }
         }
 

+ 10 - 6
app/Repositories/CmsContentTemplateSetRepository.php

@@ -8,6 +8,7 @@ use App\Models\CmsContentTemplate;
 use App\Models\CmsContentTemplateSet;
 use App\Models\CmsSubjectProduct;
 use Illuminate\Support\Facades\Cache;
+use Illuminate\Support\Facades\Redis;
 use Symfony\Component\HttpKernel\Exception\HttpException;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Database\QueryException;
@@ -472,16 +473,19 @@ class CmsContentTemplateSetRepository
             }
         }
         if ($template->apply_type == 0) {
-            if (Cache::has($group_key)) {
-                Cache::forget($group_key);
+//            if (Cache::has($group_key)) {
+//                Cache::forget($group_key);
+//            }
+            if (Redis::exists($group_key)) {
+                Redis::del($group_key);
             }
         } elseif ($template->apply_type == 1) {
-            if (Cache::has($market_key)) {
-                Cache::forget($market_key);
+            if (Redis::exists($market_key)) {
+                Redis::del($market_key);
             }
         } elseif ($template->apply_type == 2) {
-            if (Cache::has($exchange_key)) {
-                Cache::forget($exchange_key);
+            if (Redis::exists($exchange_key)) {
+                Redis::del($exchange_key);
             }
         }