duqinya 5 jaren geleden
bovenliggende
commit
ebd1e8dd00
1 gewijzigde bestanden met toevoegingen van 14 en 14 verwijderingen
  1. 14 14
      app/Repositories/CmsContentTemplateSetRepository.php

+ 14 - 14
app/Repositories/CmsContentTemplateSetRepository.php

@@ -345,21 +345,21 @@ class CmsContentTemplateSetRepository
         if (isset($request['field_order'])) {
             $field_order = intval($request['field_order']);
             if ($field_order == 2){
-                $product_keys = sprintf($product_key, md5($res_id . 2));
-            }else{
-                $product_keys = sprintf($product_key, md5($res_id . 3));
+                $product_keys = sprintf($product_key, md5($res_id . 'one' . $field_order));
+            }elseif ($field_order == 3){
+                $product_keys = sprintf($product_key, md5($res_id . 'two' . $field_order));
             }
         } else {
             $product_keys = sprintf($product_key, md5($res_id));
         }
 
-//        Log::info(Redis::exists($product_keys));
-//        if (Redis::exists($product_keys)) {
-//            $result = Redis::get($product_keys);
-//            $res = json_decode($result, true);
-//            Log::info($res);
-//            return $res;
-//        }
+        Log::info(Redis::exists($product_keys));
+        if (Redis::exists($product_keys)) {
+            $result = Redis::get($product_keys);
+            $res = json_decode($result, true);
+            Log::info($res);
+            return $res;
+        }
 
         try {
             if (isset($request['field_order'])) {
@@ -377,10 +377,10 @@ class CmsContentTemplateSetRepository
             $url = config("customer.app_service_url") . '/product/exchange/subject';
             $http = http($url, $array, 'get');
 
-//            if (!Redis::exists($product_keys)) {
-//                Redis::setex($product_keys, 300, json_encode($http));//5分钟过期
-//                Log::debug('专题商品缓存存储成功-' . json_encode($http));
-//            }
+            if (!Redis::exists($product_keys)) {
+                Redis::setex($product_keys, 300, json_encode($http));//5分钟过期
+                Log::debug('专题商品缓存存储成功-' . json_encode($http));
+            }
             return $http;
 
         } catch (\Exception $e) {