public static function setCache($reset = false) { $cache_key = self::getCacheKey(); if ($reset) { Redis::del($cache_key); } $exists = Redis::exists($cache_key); if (empty($exists)) { self::requestCache(); } }
public function incrementViewCounter() { // Only increment the view counter if the current user is a subscriber if (Auth::isSubscriber()) { $modelName = (new ReflectionClass($this))->getShortName(); $modelKey = strtolower($modelName) . '_id'; // Only increment the view counter if the user has not visited in 1 hour if (!Redis::exists($modelName . 'ViewByUser:'******':' . Auth::id())) { // Increment Redis::hincrby($modelName . ':' . $this->{$modelKey}, 'views', 1); // Add user to recent views Redis::setex($modelName . 'ViewByUser:'******':' . Auth::id(), 3600, true); } } }
public static function setAdDetailsCache($dma_code, $ad_id, $job_id, $reset = false) { $cache_key = self::getAdDetailsCacheKey($dma_code, $ad_id, $job_id); if ($reset) { Redis::del($cache_key); } $exists = Redis::exists($cache_key); if (empty($exists)) { self::requestAdDatailsCache($dma_code, $ad_id, $job_id); } }
public static function addJobToDmaCache($code, $job_id, $score) { $cache_key = self::getJobsByDmaCahceKey($code); $exists = Redis::exists($cache_key); if (empty($exists)) { self::requestJobsByDmaCache($code); } else { Redis::zadd($cache_key, $score, $job_id); } }
public static function addJobToKeywordCache($keyword, $job_id, $score) { $cache_key = self::getKeywordJobsCacheKey($keyword); $exists = Redis::exists($cache_key); if (empty($exists)) { self::requestKeywordJobsCache($keyword); } else { Redis::zadd($cache_key, $score, $job_id); } }