public function cacheData($data)
{
$file = $this->getCacheFileName();
$expiration = time() + $this->ttl;
$data['expiration'] = $expiration;
$serializedData = serialize($data);
if (self::$staticExternalCacheClass == null) {
$fh = fopen($file, 'w+');
if ($fh === false) {
throw new Exception("Failed to open " . $file);
}
fwrite($fh, $serializedData);
fclose($fh);
} else {
$staticClass = self::$staticExternalCacheClass;
$staticClass::write($this->getCacheFileName(), $serializedData);
}
}