Commit a94c5cc3 authored by Davide Aprea's avatar Davide Aprea
Browse files

add cache parameter

parent 377c22c3
......@@ -12,7 +12,7 @@ use View;
class MetaGerSearch extends Controller
{
public function search(Request $request, MetaGer $metager, $timing = false)
public function search(Request $request, MetaGer $metager, $timing = false, $nocache = false)
{
if ($request->filled("chrome-plugin")) {
return redirect(LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), "/plugin"));
......@@ -123,20 +123,21 @@ class MetaGerSearch extends Controller
$engine->markNew();
}
}
try {
Cache::put("loader_" . $metager->getSearchUid(), [
"metager" => [
"apiAuthorized" => $metager->isApiAuthorized(),
],
"adgoal" => [
"loaded" => $metager->isAdgoalLoaded(),
"adgoalHash" => $metager->getAdgoalHash(),
],
"engines" => $metager->getEngines(),
], 60 * 60);
} catch (\Exception $e) {
Log::error($e->getMessage());
if($nocache){
try {
Cache::put("loader_" . $metager->getSearchUid(), [
"metager" => [
"apiAuthorized" => $metager->isApiAuthorized(),
],
"adgoal" => [
"loaded" => $metager->isAdgoalLoaded(),
"adgoalHash" => $metager->getAdgoalHash(),
],
"engines" => $metager->getEngines(),
], 60 * 60);
} catch (\Exception $e) {
Log::error($e->getMessage());
}
}
if (!empty($timings)) {
$timings["Filled resultloader Cache"] = microtime(true) - $time;
......
......@@ -17,13 +17,17 @@ class Stresstest extends MetaGerSearch
return redirect("admin/stress/search?eingabe=test");
}
public function search(Request $request, MetaGer $metager, $timing = false)
public function search(Request $request, MetaGer $metager, $timing = false, $nocache = false)
{
if(empty($request->input('eingabe'))) {
return redirect("admin/stress/search?eingabe=test");
}
$metager->setDummy(true);
$metager->setAdgoalHash(true);
parent::search($request, $metager, $timing);
if(!empty($request->input('cache')) && $request->input('cache') === 'off') {
parent::search($request, $metager, $timing, true);
} else {
parent::search($request, $metager, $timing);
}
}
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment