From fb92a6d116c43a63cee2ef3159dfab372fa9c6b5 Mon Sep 17 00:00:00 2001 From: Dominik Hebeler <dominik@suma-ev.de> Date: Thu, 20 Feb 2020 07:42:55 +0000 Subject: [PATCH] Revert "using cache connection more" This reverts commit 2e4b5308f65e3295c687ded2cd55a63658298268 --- app/Console/Commands/RequestFetcher.php | 14 +++++++------- app/MetaGer.php | 3 ++- app/Models/Quicktips/Quicktips.php | 2 +- app/Models/Searchengine.php | 5 ++--- routes/web.php | 4 +--- 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/app/Console/Commands/RequestFetcher.php b/app/Console/Commands/RequestFetcher.php index f932b92b0..41022c5aa 100644 --- a/app/Console/Commands/RequestFetcher.php +++ b/app/Console/Commands/RequestFetcher.php @@ -56,14 +56,13 @@ class RequestFetcher extends Command try { $blocking = false; - $redis = Redis::connection("cache"); while ($this->shouldRun) { $status = curl_multi_exec($this->multicurl, $active); $currentJob = null; if (!$blocking) { - $currentJob = $redis->lpop(\App\MetaGer::FETCHQUEUE_KEY); + $currentJob = Redis::lpop(\App\MetaGer::FETCHQUEUE_KEY); } else { - $currentJob = $redis->blpop(\App\MetaGer::FETCHQUEUE_KEY, 1); + $currentJob = Redis::blpop(\App\MetaGer::FETCHQUEUE_KEY, 1); if (!empty($currentJob)) { $currentJob = $currentJob[1]; } @@ -98,8 +97,11 @@ class RequestFetcher extends Command $body = \curl_multi_getcontent($info["handle"]); } - Cache::put($resulthash, $body, $cacheDurationMinutes * 60); - + Redis::pipeline(function ($pipe) use ($resulthash, $body, $cacheDurationMinutes) { + $pipe->set($resulthash, $body); + $pipe->expire($resulthash, 60); + Cache::put($resulthash, $body, $cacheDurationMinutes * 60); + }); \curl_multi_remove_handle($this->multicurl, $info["handle"]); } if (!$active && !$answerRead) { @@ -108,8 +110,6 @@ class RequestFetcher extends Command usleep(50 * 1000); } } - } catch (\Exception $e) { - Log::error($e->getMessage()); } finally { curl_multi_close($this->multicurl); } diff --git a/app/MetaGer.php b/app/MetaGer.php index dd19664bd..47bcb73a9 100644 --- a/app/MetaGer.php +++ b/app/MetaGer.php @@ -6,6 +6,7 @@ use App; use Cache; use Carbon; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Redis; use Jenssegers\Agent\Agent; use LaravelLocalization; use Log; @@ -853,7 +854,7 @@ class MetaGer while (sizeof($enginesToWaitFor) > 0 || ($forceTimeout !== null && (microtime(true) - $timeStart) < $forceTimeout)) { foreach ($enginesToWaitFor as $index => $engine) { - if (Cache::get($engine->hash) !== null) { + if (Redis::get($engine->hash) !== null) { $answered[] = $engine; unset($enginesToWaitFor[$index]); break; diff --git a/app/Models/Quicktips/Quicktips.php b/app/Models/Quicktips/Quicktips.php index b91b69311..06306dcde 100644 --- a/app/Models/Quicktips/Quicktips.php +++ b/app/Models/Quicktips/Quicktips.php @@ -46,7 +46,7 @@ class Quicktips $mission = json_encode($mission); - Redis::connection('cache')->rpush(\App\MetaGer::FETCHQUEUE_KEY, $mission); + Redis::rpush(\App\MetaGer::FETCHQUEUE_KEY, $mission); } } diff --git a/app/Models/Searchengine.php b/app/Models/Searchengine.php index 5b131e377..ef364a50c 100644 --- a/app/Models/Searchengine.php +++ b/app/Models/Searchengine.php @@ -3,7 +3,6 @@ namespace App\Models; use App\MetaGer; -use Cache; use Illuminate\Support\Facades\Redis; abstract class Searchengine @@ -148,7 +147,7 @@ abstract class Searchengine // Submit this mission to the corresponding Redis Queue // Since each Searcher is dedicated to one specific search engine // each Searcher has it's own queue lying under the redis key <name>.queue - Redis::connection('cache')->rpush(\App\MetaGer::FETCHQUEUE_KEY, $mission); + Redis::rpush(\App\MetaGer::FETCHQUEUE_KEY, $mission); if (!empty($timings)) { $timings["startSearch"][$this->name]["pushed job"] = microtime(true) - $timings["starttime"]; } @@ -194,7 +193,7 @@ abstract class Searchengine $body = ""; } } else { - $body = Cache::get($this->hash); + $body = Redis::get($this->hash); } if ($body !== null) { diff --git a/routes/web.php b/routes/web.php index 2fa9efec4..16b658253 100644 --- a/routes/web.php +++ b/routes/web.php @@ -21,9 +21,7 @@ Route::group( /** ADD ALL LOCALIZED ROUTES INSIDE THIS GROUP **/ Route::get('/', 'StartpageController@loadStartPage'); - Route::get('sand', function () { - abort(500, "test"); - }); + Route::get('asso', function () { return view('assoziator.asso') ->with('title', trans('titles.asso')) -- GitLab