MatthiasMullie\Scrapbook\Buffered\Utils\Defer::generateRollback PHP Метод

generateRollback() защищенный Метод

Most of the operations (set, touch, ...) can't fail. We'll do those last. We'll first schedule the operations that can fail (cas, replace, add) to minimize chances of another process overwriting those values in the meantime. But it could still happen, so we should fetch the current values for all unsafe operations. If the transaction fails, we can then restore them.
protected generateRollback ( ) : array[]
Результат 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);
    }