Your IP : 216.73.216.165
<?php
// cache.php - Simple file-based caching
class SimpleCache
{
private $cacheDir = 'cache/';
private $enabled;
public function __construct($enabled = true)
{
$this->enabled = $enabled && CACHE_ENABLED;
if (!is_dir($this->cacheDir)) {
mkdir($this->cacheDir, 0755, true);
}
}
public function get($key)
{
if (!$this->enabled) return null;
$file = $this->cacheDir . md5($key) . '.cache';
if (file_exists($file) && (time() - filemtime($file)) < CACHE_DURATION) {
return unserialize(file_get_contents($file));
}
return null;
}
public function set($key, $data)
{
if (!$this->enabled) return false;
$file = $this->cacheDir . md5($key) . '.cache';
return file_put_contents($file, serialize($data));
}
}
// Global cache instance
$cache = new SimpleCache();