* @copyright (c) 2025, Robert Strutts * @license MIT */ /** * May be used by the Liquid Template Engine */ class php_file_cache { protected $cache_path; public function __construct($path) { $this->cache_path = rtrim($path, '/') . '/'; if (!is_dir($this->cache_path)) { mkdir($this->cache_path, 0775, true); } } public function get($key) { $file = $this->cache_path . md5($key) . '.cache.php'; if (file_exists($file)) { return unserialize(file_get_contents($file)); } return null; } public function set($key, $value) { $file = $this->cache_path . md5($key) . '.cache.php'; file_put_contents($file, serialize($value)); } }