NAME
Queue::DBI::Element - An object representing an element pulled from the queue.
VERSION
Version 2.0.1
SYNOPSIS
Please refer to the documentation for Queue::DBI.
METHODS
new()
Create a new Queue::DBI::Element object.
my $element = Queue::DBI::Element->new(
'queue' => $queue,
'data' => $data,
'id' => $id,
'requeue_count' => $requeue_count,
'created' => $created,
);
All parameters are mandatory and correspond respectively to the Queue::DBI object used to pull the element's data, the data, the ID of the element in the database and the number of times the element has been requeued before.
It is not recommended for direct use. You should be using the following to get Queue::DBI::Element objects:
my $queue = $queue->next();
lock()
Locks the element so that another process acting on the queue cannot get a hold of it
if ( $element->lock() )
{
print "Element successfully locked.\n";
}
else
{
print "The element has already been removed or locked.\n";
}
requeue()
In case the processing of an element has failed
if ( $element->requeue() )
{
print "Element successfully requeued.\n";
}
else
{
print "The element has already been removed or been requeued.\n";
}
success()
Removes the element from the queue after its processing has successfully been completed.
if ( $element->success() )
{
print "Element successfully removed from queue.\n";
}
else
{
print "The element has already been removed.\n";
}
data()
Returns the data initially queued.
my $data = $element->data();
requeue_count()
Returns the number of times that the current element has been requeued.
my $requeue_count = $element->requeue_count();
id()
Returns the ID of the current element
my $id = $element->id();
get_created_time()
Returns the unixtime at which the element was originally created.
my $created = $element->get_created_time();
is_over_lifetime()
Returns a boolean indicating whether the current element is over the lifetime specified when instanciating the queue. This is especially helpful if you retrieve a large batch of elements and do long processing operations on each of them.
my $is_over_lifetime = $element->is_over_lifetime();
INTERNAL METHODS
get_queue()
Returns the Queue::DBI object used to pull the current element.
my $queue = $element->get_queue();
AUTHOR
Guillaume Aubert, <aubertg at cpan.org>
.
BUGS
Please report any bugs or feature requests to bug-queue-dbi at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Queue-DBI. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Queue::DBI::Element
You can also look for information at:
RT: CPAN's request tracker
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
ACKNOWLEDGEMENTS
Thanks to ThinkGeek (http://www.thinkgeek.com/) and its corporate overlords at Geeknet (http://www.geek.net/), for footing the bill while I write code for them!
Thanks to Jacob Rose <jacob at thinkgeek.com>
, who wrote the first queueing module at ThinkGeek http://www.thinkgeek.com and whose work provided the inspiration to write this full-fledged queueing system.
Thanks to Jamie McCarthy for the locking mechanism improvements in version 1.1.0.
Thanks to Sergey Bond for suggesting many features added in version 1.8.x (lifetime constraint, purge() function, get/set functions cleanup).
COPYRIGHT & LICENSE
Copyright 2009-2012 Guillaume Aubert.
This program is free software; you can redistribute it and/or modify it under the terms of the Artistic License.
See http://dev.perl.org/licenses/ for more information.