Exemplo n.º 1
0
 /**
  * The boot() method is called right before a request is routed
  */
 public function boot()
 {
     if (Configs::get('cache_time_out') == null) {
         Configs::set('cache_time_out', 'daily');
     }
     if (Configs::get('fetch_with_cron') == null) {
         Configs::set('fetch_with_cron', '1');
     }
     if (Configs::get('timezone') == null) {
         Configs::set('timezone', 'America/Los_Angeles');
     }
     date_default_timezone_set(Configs::get('timezone'));
 }
Exemplo n.º 2
0
 /**
  * Checks for if cache timeout
  *
  * @return boolean
  */
 public function needUpdateCount()
 {
     $timeVars = ['everyFiveMinutes' => 5, 'everyTenMinutes' => 10, 'everyThirtyMinutes' => 30, 'hourly' => 60, 'daily' => 1440, 'weekly' => 10080, 'monthly' => 43200, 'yearly' => 525600];
     // $timeVars[ Configs::get('cache_time_out') ] * 60
     if (time() - strtotime($this->urlData['last_fetched']) > $timeVars[Configs::get('cache_time_out')] * 60) {
         // lets update counts
         return true;
     } else {
         // no need to update yet
         return false;
     }
 }