NAME
Redis::Queue - Simple work queue using Redis
VERSION
Version 0.01
SYNOPSIS
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();
...
CONSTRUCTOR
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
THREADSAFE METHODS
Atomic thread-safe methods.
sendMessage
Put a message on the queue. Returns the generated message id.
receiveMessage
Get a message from the queue. Returns (id,value). You must use the id to delete the message when done.
deleteMessage
Delete a message from the queue by id.
NON-THREADSAFE METHODS
These methods return results that may not accurately represent the state of the queue by the time you read their results.
length
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.
nuke
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.
peekMessages
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.
queues
Get the list of queues hosted on the redis server.
PRIVATE METHODS
Documentation here provided for developer reference.
_queue_base
Accessor method for the queue key-name prefix
_call_redis
Send a request to Redis
AUTHOR
Alex Popiel, <tapopiel+redisqueue at gmail.com>
BUGS
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.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Redis::Queue
You can also look for information at:
GitHub
AnnoCPAN: Annotated CPAN documentation
ACKNOWLEDGEMENTS
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.
LICENSE AND COPYRIGHT
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.