src/Buffered/Utils/Defer.php
protected function sortUpdates(array $a, array $b)
    {
        $updateOrder = array(
            // there's no point in applying this after doing the below updates
            // we also shouldn't really worry about cas/replace failing after this,
            // there won't be any after cache having been flushed
            'flush',

            // prone to fail: they depend on certain conditions (token must match
            // or value must (not) exist)
            'cas',
            'replace',
            'add',

            // unlikely/impossible to fail, assuming the input is valid
            'touch',
            'increment',
            'decrement',
            'set', 'setMulti',
            'delete', 'deleteMulti',
        );

        if ($a[0] === $b[0]) {
            return 0;
        }

        return array_search($a[0], $updateOrder) < array_search($b[0], $updateOrder) ? -1 : 1;
    }
protected function sortUpdates(array $a, array $b)
    {
        $updateOrder = array(
            // there's no point in applying this after doing the below updates
            // we also shouldn't really worry about cas/replace failing after this,
            // there won't be any after cache having been flushed
            'flush',

            // prone to fail: they depend on certain conditions (token must match
            // or value must (not) exist)
            'cas',
            'replace',
            'add',

            // unlikely/impossible to fail, assuming the input is valid
            'touch',
            'increment',
            'decrement',
            'set', 'setMulti',
            'delete', 'deleteMulti',
        );

        if ($a[0] === $b[0]) {
            return 0;
        }

        return array_search($a[0], $updateOrder) < array_search($b[0], $updateOrder) ? -1 : 1;
    }
protected function sortUpdates ( array $ a , array $ b ) { $ updateOrder = array ( // there's no point in applying this after doing the below updates // we also shouldn't really worry about cas/replace failing after this, // there won't be any after cache having been flushed 'flush' , // prone to fail: they depend on certain conditions (token must match // or value must (not) exist) 'cas' , 'replace' , 'add' , // unlikely/impossible to fail, assuming the input is valid 'touch' , 'increment' , 'decrement' , 'set' , 'setMulti' , 'delete' , 'deleteMulti' , ) ; if ( $ a [ 0 ] === $ b [ 0 ] ) { return 0 ; } return array_search ( $ a [ 0 ] , $ updateOrder ) < array_search ( $ b [ 0 ] , $ updateOrder ) ? - 1 : 1 ; }
Change the order of the updates in this transaction to ensure we have those
most likely to fail first. That'll decrease odds of having to roll back, and
make rolling back easier.

@param array $a Update, where index 0 is the operation name
@param array $b Update, where index 0 is the operation name

@return int
Change the order of the updates in this transaction to ensure we have those most likely to fail first . That ll decrease odds of having to roll back and make rolling back easier .