public function flush(
        int $bulkNumber = 500,
        bool $skipIfLess = false
    ) {
        if (
            $skipIfLess &&
            count($this->elementsToUpdate) < $bulkNumber
        ) {
            return;
        }

        $offset = 0;

        try {
            while (true) {
                $items = array_slice(
                    $this->elementsToUpdate,
                    $offset,
                    $bulkNumber
                );

                if (empty($items)) {
                    break;
                }

                $this->flushItems($items, []);
                $offset += $bulkNumber;
            }

            $this->flushItems([], $this->elementsToDelete);
        } catch (Exception $exception) {
            /*
             * No matter the exception is thrown, cached elements should be
             * deleted
             */
            $this->resetCachedElements();

            throw $exception;
        }

        $this->resetCachedElements();
    }
public function flush(
        int $bulkNumber = 500,
        bool $skipIfLess = false
    ) {
        if (
            $skipIfLess &&
            count($this->elementsToUpdate) < $bulkNumber
        ) {
            return;
        }

        $offset = 0;

        try {
            while (true) {
                $items = array_slice(
                    $this->elementsToUpdate,
                    $offset,
                    $bulkNumber
                );

                if (empty($items)) {
                    break;
                }

                $this->flushItems($items, []);
                $offset += $bulkNumber;
            }

            $this->flushItems([], $this->elementsToDelete);
        } catch (Exception $exception) {
            /*
             * No matter the exception is thrown, cached elements should be
             * deleted
             */
            $this->resetCachedElements();

            throw $exception;
        }

        $this->resetCachedElements();
    }
public function flush ( int $ bulkNumber = 500 , bool $ skipIfLess = false ) { if ( $ skipIfLess && count ( $ this -> elementsToUpdate ) < $ bulkNumber ) { return ; } $ offset = 0 ; try { while ( true ) { $ items = array_slice ( $ this -> elementsToUpdate , $ offset , $ bulkNumber ) ; if ( empty ( $ items ) ) { break ; } $ this -> flushItems ( $ items , [ ] ) ; $ offset += $ bulkNumber ; } $ this -> flushItems ( [ ] , $ this -> elementsToDelete ) ; } catch ( Exception $ exception ) { /*
             * No matter the exception is thrown, cached elements should be
             * deleted
             */ $ this -> resetCachedElements ( ) ; throw $ exception ; } $ this -> resetCachedElements ( ) ; }
Flush all.

This flush can be avoided if not enough items have been generated by
setting $skipIfLess = true

@param int  $bulkNumber
@param bool $skipIfLess

@throws ResourceNotAvailableException
@throws Exception
Flush all .