Browse Source

Cache::get => Cache::remember

visuddhinanda 4 days ago
parent
commit
bcf0c0dd46

+ 2 - 2
api-v13/app/Http/Controllers/DhammaTermController.php

@@ -150,7 +150,7 @@ class DhammaTermController extends Controller
                 break;
                 break;
             case 'hot-meaning':
             case 'hot-meaning':
                 $key = 'term/hot_meaning';
                 $key = 'term/hot_meaning';
-                $value = Cache::get($key, function () use ($request) {
+                $value = Cache::remember($key, config('mint.cache.expire'), function () use ($request) {
                     $hotMeaning = [];
                     $hotMeaning = [];
                     $words = DhammaTerm::select('word')
                     $words = DhammaTerm::select('word')
                         ->where('language', $request->input("language"))
                         ->where('language', $request->input("language"))
@@ -176,7 +176,7 @@ class DhammaTermController extends Controller
                     }
                     }
                     Cache::put($key, $hotMeaning, 3600);
                     Cache::put($key, $hotMeaning, 3600);
                     return $hotMeaning;
                     return $hotMeaning;
-                }, config('mint.cache.expire'));
+                });
                 return $this->ok(["rows" => $value, "count" => count($value)]);
                 return $this->ok(["rows" => $value, "count" => count($value)]);
                 break;
                 break;
             default:
             default:

+ 2 - 2
api-v13/app/Http/Controllers/ProgressImgController.php

@@ -40,7 +40,7 @@ class ProgressImgController extends Controller
         //
         //
         return response()->stream(function () use ($id) {
         return response()->stream(function () use ($id) {
             $key = str_replace('-', '/', $id);
             $key = str_replace('-', '/', $id);
-            $svg = Cache::get('svg/' . $key, function () use ($key) {
+            $svg = Cache::remember('svg/' . $key, config('mint.cache.expire'), function () use ($key) {
                 $viewHeight = 60;
                 $viewHeight = 60;
                 $svg = "<svg xmlns='http://www.w3.org/2000/svg'  fill='currentColor' viewBox='0 0 300 60'>";
                 $svg = "<svg xmlns='http://www.w3.org/2000/svg'  fill='currentColor' viewBox='0 0 300 60'>";
                 $data = Cache::get($key);
                 $data = Cache::get($key);
@@ -55,7 +55,7 @@ class ProgressImgController extends Controller
                     $svg .= '<polyline points="0,0 1,0" /></svg>';
                     $svg .= '<polyline points="0,0 1,0" /></svg>';
                 }
                 }
                 return $svg;
                 return $svg;
-            }, config('mint.cache.expire'));
+            });
             echo $svg;
             echo $svg;
         }, 200, ['Content-Type' => 'image/svg+xml']);
         }, 200, ['Content-Type' => 'image/svg+xml']);
         /*
         /*