--- AnyEvent-DBI/README 2010/10/30 20:23:44 1.6 +++ AnyEvent-DBI/README 2017/08/15 07:31:06 1.7 @@ -32,9 +32,10 @@ It means that you can run DBI requests in parallel to other tasks. - The overhead for very simple statements ("select 0") is somewhere around - 100% to 120% (dual/single core CPU) compared to an explicit - prepare_cached/execute/fetchrow_arrayref/finish combination. + With DBD::mysql, the overhead for very simple statements ("select 0") is + somewhere around 50% compared to an explicit + prepare_cached/execute/fetchrow_arrayref/finish combination. With + DBD::SQlite3, it's more like a factor of 8 for this trivial statement. ERROR HANDLING This module defines a number of functions that accept a callback @@ -45,7 +46,7 @@ otherwise there will only be the $dbh argument and $@ contains an error message. - A convinient way to check whether an error occured is to check $#_ - if + A convenient way to check whether an error occurred is to check $#_ - if that is true, then the function was successful, otherwise there was an error. @@ -95,18 +96,24 @@ AnyEvent::DBI will not "die". You still cannot, however, use the $dbh object you received from "new" to make requests. - exec_server => 1 - If you supply an "exec_server" argument, then the DBI server - process will fork and exec another perl interpreter (using $^X) - with just the AnyEvent::DBI proxy running. This will provide the - cleanest possible proxy for your database server. - - If you do not supply the "exec_server" argument (or supply it - with a false value) then the traditional method of starting the - server by forking the current process is used. The forked - interpreter will try to clean itself up by calling POSIX::close - on all file descriptors except STDIN, STDOUT, and STDERR (and - the socket it uses to communicate with the cilent, of course). + fork_template => $AnyEvent::Fork-object + "AnyEvent::DBI" uses "AnyEvent::Fork->new" to create the + database slave, which in turn either "exec"'s a new process + (similar to the old "exec_server" constructor argument) or uses + a process forked early (see AnyEvent::Fork::Early). + + With this argument you can provide your own fork template. This + can be useful if you create a lot of "AnyEvent::DBI" handles and + want to save memory (And speed up startup) by not having to load + "AnyEvent::DBI" again and again into your child processes: + + my $template = AnyEvent::Fork + ->new # create new template + ->require ("AnyEvent::DBI::Slave"); # preload AnyEvent::DBI::Slave module + + for (...) { + $dbh = new AnyEvent::DBI ... + fork_template => $template; timeout => seconds If you supply a timeout parameter (fractional values are @@ -131,8 +138,8 @@ Any additional key-value pairs will be rolled into a hash reference and passed as the final argument to the "DBI->connect (...)" call. - For example, to supress errors on STDERR and send them instead to an - AnyEvent::Handle you could do: + For example, to suppress errors on STDERR and send them instead to + an AnyEvent::Handle you could do: $dbh = new AnyEvent::DBI "DBI:mysql:test;mysql_read_default_file=/root/.my.cnf", "", "", @@ -148,6 +155,18 @@ Sets (or clears, with "undef") the database timeout. Useful to extend the timeout when you are about to make a really long query. + $dbh->attr ($attr_name[, $attr_value], $cb->($dbh, $new_value)) + An accessor for the database handle attributes, such as + "AutoCommit", "RaiseError", "PrintError" and so on. If you provide + an $attr_value (which might be "undef"), then the given attribute + will be set to that value. + + The callback will be passed the database handle and the attribute's + value if successful. + + If an error occurs and the "on_error" callback returns, then only + $dbh will be passed and $@ contains the error message. + $dbh->exec ("statement", @args, $cb->($dbh, \@rows, $rv)) Executes the given SQL statement with placeholders replaced by @args. The statement will be prepared and cached on the server side, @@ -164,11 +183,9 @@ If an error occurs and the "on_error" callback returns, then only $dbh will be passed and $@ contains the error message. - $dbh->attr ($attr_name[, $attr_value], $cb->($dbh, $new_value)) - An accessor for the handle attributes, such as "AutoCommit", - "RaiseError", "PrintError" and so on. If you provide an $attr_value - (which might be "undef"), then the given attribute will be set to - that value. + $dbh->stattr ($attr_name, $cb->($dbh, $value)) + An accessor for the statement attributes of the most recently + executed statement, such as "NAME" or "TYPE". The callback will be passed the database handle and the attribute's value if successful. @@ -227,8 +244,8 @@ SEE ALSO AnyEvent, DBI, Coro::Mysql. -AUTHOR - Marc Lehmann +AUTHOR AND CONTACT + Marc Lehmann (current maintainer) http://home.schmorp.de/ Adam Rosenstein