diff --git a/app/Models/Quicktips/Quicktips.php b/app/Models/Quicktips/Quicktips.php index c8b14c273a53cdf0cac6ec985dc35272f8af82a6..0bfc673a802ed7511d514feb49c9d30353e9e345 100644 --- a/app/Models/Quicktips/Quicktips.php +++ b/app/Models/Quicktips/Quicktips.php @@ -32,24 +32,25 @@ class Quicktips $url = $this->quicktipUrl . "?search=" . $this->normalize_search($search) . "&locale=" . $locale; $this->hash = md5($url); - - if (!Redis::exists($this->hash)) { - - // Queue this search - $mission = [ - "resulthash" => $this->hash, - "url" => $url, - "useragent" => "", - "username" => null, - "password" => null, - "headers" => [], - "cacheDuration" => self::CACHE_DURATION, - "name" => "Quicktips", - ]; - - $mission = json_encode($mission); - - Redis::rpush(\App\MetaGer::FETCHQUEUE_KEY, $mission); + if (!Cache::has($this->hash)) { + if (!Redis::exists($this->hash)) { + + // Queue this search + $mission = [ + "resulthash" => $this->hash, + "url" => $url, + "useragent" => "", + "username" => null, + "password" => null, + "headers" => [], + "cacheDuration" => self::CACHE_DURATION, + "name" => "Quicktips", + ]; + + $mission = json_encode($mission); + + Redis::rpush(\App\MetaGer::FETCHQUEUE_KEY, $mission); + } } } @@ -76,6 +77,10 @@ class Quicktips $startTime = microtime(true); + if ($cache::has($this->hash)) { + return Cache::get($this->hash, false); + } + while (microtime(true) - $startTime < 0.5) { $body = Redis::rpoplpush($this->hash, $this->hash); if ($body === false || $body === null) {