
Queue::Q4M - Simple Interface To q4m

use Queue::Q4M;
my $q = Queue::Q4M->connect(
connect_info => [
'dbi:mysql:dbname=mydb',
$username,
$password
],
);
for (1..10) {
$q->insert($table, \%fieldvals);
}
while ($q->next($table)) {
my ($col1, $col2, $col3) = $q->fetch($table, \@fields);
print "col1 = $col1, col2 = $col2, col3 = $col3\n";
}
while ($q->next($table)) {
my $cols = $q->fetch_arrayref($table, \@fields);
print "col1 = $cols->[0], col2 = $cols->[1], col3 = $cols->[2]\n";
}
while ($q->next($table)) {
my $cols = $q->fetch_hashref($table, \@fields);
print "col1 = $cols->{col1}, col2 = $cols->{col2}, col3 = $cols->{col3}\n";
}
# to use queue_wait(table_cond1,table_cond2,timeout)
while (my $which = $q->next(@table_conds)) {
# $which contains the table name
}
$q->disconnect;

Queue::Q4M is a simple wrapper to q4m, which is an implementation of a queue using mysql.

Creates a new Queue::Q4M instance. Normally you should use connect() instead.
Connects to the target database.
my $q = Queue::Q4M->connect(
connect_info => [
'dbi:mysql:dbname=q4m',
]
);
Blocks until the next item is available. This is equivalent to calling queue_wait() on the given table.
my $which = $q->next( $table_cond1, $table_cond2, $table_cond3 );
Fetches the next available row. Takes the list of columns to be fetched.
my ($col1, $col2, $col3) = $q->fetch( $table, [ qw(col1 col2 col3) ] );
Same as fetch_array, but fetches using fetchrow_arrayref()
my $arrayref = $q->fetch_arrayref( $table, [ qw(col1 col2 col3) ] );
Same as fetch_array, but fetches using fetchrow_hashref()
my $hashref = $q->fetch_hashref( $table, [ qw(col1 col2 col3) ] );
Inserts into the queue. The first argument should be a scalar specifying a table name. The second argument is a hashref that specifies the mapping between column names and their respective values.
$q->insert($table, { col1 => $val1, col2 => $val2, col3 => $val3 });
For backwards compatibility, you may omit $table if you specified $table in the constructor.
Deletes everything the specified queue. Be careful!
Returns the database handle after making sure that it's connected.
Disconnects.
These are defined as part of Moose infrastructure

Copyright (c) 2008 Daisuke Maki <daisuke@endeworks.jp>

Taro Funaki

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.