Redis::Queue - Simple work queue using Redis
Simple work queue using Redis, tries not to lose things when processes die.
Worker should call receiveMessage to get a unit of work, and deleteMessage once the work is completed. If the message isn't deleted within a given timeout, other workers can retrieve the message again.
The queue object should be kept around for a while, because of the 'id' state that it keeps when generating new entries. If you have concerns about the redis connection dropping, pass a constructor as the $redis parameter isntead of a connection.
use Redis::Queue; my $foo = Redis::Queue->new(); ...
Required parameters: redis => handle to Redis || coderef to generate a handle to Redis queue => name for queue Optional parameters: timeout => length of time (in seconds) to treat received messages as reserved
Atomic thread-safe methods.
Put a message on the queue. Returns the generated message id.
Get a message from the queue. Returns (id,value). You must use the id to delete the message when done.
Delete a message from the queue by id.
These methods return results that may not accurately represent the state of the queue by the time you read their results.
Get the length of the queue. It may have changed by the time you read it but it's good for a general idea of how big the queue is.
Delete all storage associated with the queue. Messy things may happen if something else is trying to use the queue at the same time this runs. On the other hand, it shouldn't be fatal, but still leaves the the possibility of leaving some stuff behind.
Peek at some number of messages on the queue (defaults to 10). In particular, if there are workers deleting entries, this may return fewer entries than requested, even if there are more messages on the queue.
Get the list of queues hosted on the redis server.
Documentation here provided for developer reference.
Accessor method for the queue key-name prefix
Send a request to Redis
<tapopiel+redisqueue at gmail.com>
Please report any bugs or feature requests to
bug-redis-queue at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Redis-Queue. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
You can find documentation for this module with the perldoc command.
You can also look for information at:
Thank you to Marchex http://www.marchex.com/ for allowing time to be spent developing and maintaining this library. Thanks also to Chris Petersen for major assistance in packaging of this library.
Copyright 2011 Alex Popiel.
This program is free software; you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.
See http://www.perlfoundation.org/artistic_license_2_0 for more information.