NAME

OP::Persistence::Bulk - Deferred fast bulk table writes

SYNOPSIS

use OP qw| :all |;
use OP::Persistence::Bulk;

use YourApp::Example;

#
# Queue up a bunch of objects for save:
#
for ( ... ) {
  my $exa = YourApp::Example->new(...);

  #
  # Queue object in the currently active scratch file:
  #
  $exa->stash;
}

#
# Write any deferred saves to the database with blazing speed:
#
YourApp::Example->flushStash;

DESCRIPTION

Experimental mix-in module to enable the saving of many objects to the database at once, using MySQL's LOAD FILE syntax, which is extremely fast.

Saving objects in this manner will bypass many application and db-level constraints, which can result in disasterous consequences if the objects contain garbage data. This is a very sharp knife.

BUGS

Using this mix-in with classes that have attributes possessing sqlValue insert/update overrides, such as those descended from OP::RRNode, will probably not work as-is. Any necessary logic for handling insert/update value overrides may be defined in a class's _prestash method, which is called prior to stashing.

SEE ALSO

This file is part of OP.