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;
}
/** * 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; }