protected function rollback(array $old, array $new)
{
foreach ($old as $key => $value) {
$current = $this->cache->get($key, $token);
/*
* If the value right now equals the one we planned to write, it
* should be restored to what it was before. If it's yet something
* else, another process must've stored it and we should leave it
* alone.
*/
if ($current === $new) {
/*
* CAS the rollback. If it fails, that means another process
* has stored in the meantime and we can just leave it alone.
* Note that we can't know the original expiration time!
*/
$this->cas($token, $key, $value, 0);
}
}
$this->clear();
}