protected generateRollback ( ) : array[] | ||
return | array[] | Array of 2 [key => value] maps: current & scheduled data |
protected function generateRollback()
{
$keys = array();
$new = array();
foreach ($this->keys as $key => $data) {
$operation = $data[0];
// we only need values for cas & replace - recovering from an 'add'
// is just deleting the value...
if (in_array($operation, array('cas', 'replace'))) {
$keys[] = $key;
$new[$key] = $data[2]['value'];
}
}
if (empty($keys)) {
return array(array(), array());
}
// fetch the existing data & return the planned new data as well
$current = $this->cache->getMulti($keys);
return array($current, $new);
}