|
NAMEQueue::Beanstalk - Client library for the beanstalkd serverSYNOPSISProducer example:use Queue::Beanstalk; $jobs = Queue::Beanstalk->new( 'servers' => [ '127.0.0.1:11300' ], 'connect_timeout' => 2, ); # Adds a job with priority 4294967295 and 0 delay $jobs->put('do:something'); # Adds a job with 0 (highest) priority and 1 second delay $jobs->put(('do:somethingelse', 0, 1); Worker example: use Queue::Beanstalk; $jobs = Queue::Beanstalk->new( 'servers' => [ '127.0.0.1:11300' ], 'connect_timeout' => 2, ); while (1) { my $data; if ($data = $jobs->reserve()) { if (do_something($data)) { $jobs->delete(); # done with the job } else { $jobs->release(); # i failed, let someone else take it } $jobs->next_server(); # optional, if you have several servers } sleep(1); # prevent cpu intensive loop (just in case) } WARNING! This module is marked as being in the alpha stage, and is therefore subject to change in near future. This version of Queue::Beanstalk currently supports the 0.6 protocol version of Beanstalkd. DESCRIPTIONClient library for Beanstalk. Read more about the Beanstalkd daemon athttp://xph.us/software/beanstalkd/ CONSTRUCTOR"new"Has the following hashref options:
METHODS"put"$jobs->put($job_data[, $priority, $delay])Insert a job into the queue. Priority is an integer between 0 (highest) and 4294967295 (lowest). Default priority is 4294967295. Default delay is 0. Returns an undefined value on errors, 'inserted' or 'burried'. "stats"$jobs->stats();Returns YAML stats output from beanstalkd. TODO: Parse yaml and return hashref. "reserve"$jobs->reserve();Returns undef on failure/timeout, or full job-data if successful. You have 120 seconds to fullfil the job, before beanstalkd gives up on you. "release"$jobs->release([$priority, $delay]);Release the current reserved job. The default is to use the same priority as the job had, and 0 second delay. "delete"$jobs->delete();Delete the current reserved job. Removes the job from the queue as the job is finished. AUTHORHaakon Nessjoen, Loopback Systems AS, <lunatic@cpan.org>COPYRIGHT AND LICENSECopyright (c) 2007 by Loopback Systems ASThis library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available. POD ERRORSHey! The above document had some coding errors, which are explained below:
Visit the GSP FreeBSD Man Page Interface. |