_type = $type; $this->_cache_time = $cache_time; switch ($type) { case 'file': $this->_adapter = null; break; default: break; } } /** * Set cache Key * * @param string $key * @param mixed $value * @return void */ public function set($key, $value) { file_put_contents(__DIR__ . '/../config/' . md5($key) . '.json', json_encode($value)); } public function get($key) { $file_path = __DIR__ . '/../config/' . md5($key) . '.json'; if (file_exists($file_path)) { if (time() - $this->_cache_time < filemtime($file_path)) { $data = file_get_contents($file_path); return json_decode($data, TRUE); } else { unlink($file_path); } } return NULL; } public function remove($key) { $file_path = __DIR__ . '/../config/' . md5($key) . '.json'; if (file_exists($file_path)) { unlink($file_path); return TRUE; } return NULL; } }