function set($key, $data)
{
$dir = c::get('cache.dir');
if (!is_dir($dir) or !is_writable($dir)) {
return false;
}
$cache_path = self::name($key);
if (!($fp = fopen($cache_path, 'wb'))) {
return false;
}
if (flock($fp, LOCK_EX)) {
fwrite($fp, serialize($data));
flock($fp, LOCK_UN);
} else {
return false;
}
fclose($fp);
@chmod($cache_path, 0777);
return true;
}