diff --git a/app/Console/Commands/RequestFetcher.php b/app/Console/Commands/RequestFetcher.php index 41022c5aab9dcfa7c8da8a355f89ddecbf532c15..f932b92b0339f5ec9d85d6e24ddfacd23af53372 100644 --- a/app/Console/Commands/RequestFetcher.php +++ b/app/Console/Commands/RequestFetcher.php @@ -56,13 +56,14 @@ 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]; } @@ -97,11 +98,8 @@ class RequestFetcher extends Command $body = \curl_multi_getcontent($info["handle"]); } - Redis::pipeline(function ($pipe) use ($resulthash, $body, $cacheDurationMinutes) { - $pipe->set($resulthash, $body); - $pipe->expire($resulthash, 60); - Cache::put($resulthash, $body, $cacheDurationMinutes * 60); - }); + Cache::put($resulthash, $body, $cacheDurationMinutes * 60); + \curl_multi_remove_handle($this->multicurl, $info["handle"]); } if (!$active && !$answerRead) { @@ -110,6 +108,8 @@ 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 47bcb73a9d50476bcf29cefafbdd7d26021704da..dd19664bd442791ad9fbe6bb084756828988d763 100644 --- a/app/MetaGer.php +++ b/app/MetaGer.php @@ -6,7 +6,6 @@ use App; use Cache; use Carbon; use Illuminate\Http\Request; -use Illuminate\Support\Facades\Redis; use Jenssegers\Agent\Agent; use LaravelLocalization; use Log; @@ -854,7 +853,7 @@ class MetaGer while (sizeof($enginesToWaitFor) > 0 || ($forceTimeout !== null && (microtime(true) - $timeStart) < $forceTimeout)) { foreach ($enginesToWaitFor as $index => $engine) { - if (Redis::get($engine->hash) !== null) { + if (Cache::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 06306dcde031b42f5b8b3f9cfd208d8e7a0f7680..b91b693110186c460d2ee6b6c03541c1ba8edc9a 100644 --- a/app/Models/Quicktips/Quicktips.php +++ b/app/Models/Quicktips/Quicktips.php @@ -46,7 +46,7 @@ class Quicktips $mission = json_encode($mission); - Redis::rpush(\App\MetaGer::FETCHQUEUE_KEY, $mission); + Redis::connection('cache')->rpush(\App\MetaGer::FETCHQUEUE_KEY, $mission); } } diff --git a/app/Models/Searchengine.php b/app/Models/Searchengine.php index ef364a50c2ae6794752508c67afbcf2c12c31418..5b131e377af4feca4dabdd8df84fcf901f527d14 100644 --- a/app/Models/Searchengine.php +++ b/app/Models/Searchengine.php @@ -3,6 +3,7 @@ namespace App\Models; use App\MetaGer; +use Cache; use Illuminate\Support\Facades\Redis; abstract class Searchengine @@ -147,7 +148,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::rpush(\App\MetaGer::FETCHQUEUE_KEY, $mission); + Redis::connection('cache')->rpush(\App\MetaGer::FETCHQUEUE_KEY, $mission); if (!empty($timings)) { $timings["startSearch"][$this->name]["pushed job"] = microtime(true) - $timings["starttime"]; } @@ -193,7 +194,7 @@ abstract class Searchengine $body = ""; } } else { - $body = Redis::get($this->hash); + $body = Cache::get($this->hash); } if ($body !== null) { diff --git a/routes/web.php b/routes/web.php index 16b658253b881a5d38385eea7c4137c440d95e78..2fa9efec45f52045b7cbe46a0846bd6e776e8ca6 100644 --- a/routes/web.php +++ b/routes/web.php @@ -21,7 +21,9 @@ 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'))