public function commit()
{
list($old, $new) = $this->generateRollback();
$updates = $this->generateUpdates();
$updates = $this->combineUpdates($updates);
usort($updates, array($this, 'sortUpdates'));
foreach ($updates as $update) {
// apply update to cache & receive a simple bool to indicate
// success (true) or failure (false)
$success = call_user_func_array($update[1], $update[2]);
if ($success === false) {
$this->rollback($old, $new);
return false;
}
}
$this->clear();
return true;
}
/** * Commits all deferred updates to real cache. * that had already been written to will be deleted. * * @return bool */ public function commit() { $this->clear(); return $this->defer->commit(); }