public function get($key)
{
$key = md5($key);
if (!file_exists($this->tmp_dir . $key)) {
return null;
}
$file = fopen($this->tmp_dir . $key, "r");
flock($file, LOCK_EX);
$data = fgets($file);
flock($file, LOCK_UN);
fclose($file);
return unserialize(base64_decode($data));
}
public function testFileSystemCache() { $cache = new FileSystemCacheHandler(); $this->assertNull($cache->get('pepe')); $cache->set('pepe', 'lala'); $this->assertEquals('lala', $cache->get('pepe')); $cache->delete('pepe'); $this->assertNull($cache->get('pepe')); }