Gilbitron\Util\SimpleCache::is_cached PHP Méthode

is_cached() public méthode

public is_cached ( $label )
    public function is_cached($label)
    {
        $filename = $this->cache_path . $this->safe_filename($label) . $this->cache_extension;
        if (file_exists($filename) && filemtime($filename) + $this->cache_time >= time()) {
            return true;
        }
        return false;
    }

Usage Example

Exemple #1
0
 /**
  * Gets cached data
  *
  * @return $this
  * @throws DataNotLoadedException
  */
 protected function withCache()
 {
     $this->type = 'fromCache';
     $data = $this->cache->is_cached($this->label) ? $this->cache->get_cache($this->label) : false;
     $this->data = $data ? json_decode($data, true) : false;
     if (!$this->data) {
         $this->cache->set_cache($this->label, json_encode($this->withoutCache()->get()));
     }
     return $this;
 }