public function set($key, $value) { $key = md5($key); $value = base64_encode(serialize($value)); $file = fopen($this->tmp_dir . $key, "w+"); flock($file, LOCK_EX); fwrite($file, $value, strlen($value)); flock($file, LOCK_UN); fclose($file); }
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')); }