Skip to content

logie17/DB-Evented

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NAME

DB::Evented - A pragmatic DBI like evented module.

SYNOPSIS

Doing selects in synchronise order is not always the most efficient way to interact with the Database.

use DB::Evented;

my $evented = DB::Evented->new("DBI:SQLite2:dbname=$dname", "","");

my $results;
$evented->selectcol_arrayref(
  q{
    select
      test1,
      test2
    from
      test
  },
  { 
    Columns => [1,2],
    response => sub {
        $results->{result1} = shift;
    }           
  }
);

$evented->selectrow_hashref(
  q{
    select
      test1,
      test2
    from
      test
  },
  {
    response => sub {
      $results->{result2} = shift;
    }
  }
);

$evented->execute_in_parallel;

STATIC METHODS

new ($connection_str, $username, $pass, %dbi_args )

In order to initialize a DB::Evented object a connection_str is most likely required. See AnyEvent::DBI for more information.

INSTANCE METHODS

any_event_handler

This will return an AnyEvent::DBI handler. The key difference between this handler and DBI is that it's using AnyEvent under the hood. What does this mean? It means that if you use an AnyEvent::DBI method it will run asynchronously.

clear_handlers

Clears all handlers

clear_queue

Clears the queue of any db todos

execute_in_parallel

Will execute all of the queued statements in parallel. This will create a pool of handlers and cache them if necessary.

selectall_arrayref ($sql, \%attr, @binds )

This method functions in the same way as DBI::selectall_arrayref. The key difference being it delays the execution until execute_in_parallel has been called. The results can be accessed in the response attribute call back

selectall_hashref ($sql, $key_field, \%attr, @binds )

This method functions in the same way as DBI::selectall_hashref. The key difference being it delays the execution until execute_in_parallel has been called. The results can be accessed in the response attribute call back

selectrow_arrayref ($sql, \%attr, @binds )

This method functions in the same way as DBI::selectrow_arrayref. The key difference being it delays the execution until execute_in_parallel has been called. The results can be accessed in the response attribute call back

selectrow_hashref ($sql, \%attr, @binds )

This method functions in the same way as DBI::selectrow_hashref. The key difference being it delays the execution until execute_in_parallel has been called. The results can be accessed in the response attribute call back

AUTHOR

Logan Bell, <logie at cpan.org>

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc DB::Evented

You can also look for information at:

ACKNOWLEDGEMENTS

Aaron Cohen and Belden Lyman.

LICENSE

Copyright (c) 2013 Logan Bell and Shutterstock Inc (http://shutterstock.com). All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages