Queue::Q::NaiveFIFO::Redis - In-memory Redis implementation of the NaiveFIFO queue
use Queue::Q::NaiveFIFO::Redis; my $q = Queue::Q::NaiveFIFO::Redis->new( server => 'myredisserver', port => 6379, queue_name => 'my_work_queue', ); $q->enqueue_item("foo"); $q->enqueue_item({ bar => "baz" }); # any Sereal-serializable data structure my $foo = $q->claim_item; my $bar = $q->claim_item;
Implements interface defined in Queue::Q::NaiveFIFO: an implementation based on Redis lists.
The data structures passed to enqueue_item are serialized using Sereal (cf. Sereal::Encoder, Sereal::Decoder), so any data structures supported by that can be enqueued.
enqueue_item
All methods of Queue::Q::NaiveFIFO plus:
Constructor. Takes named parameters. Required parameters are the server hostname or address, the Redis port, and the name of the Redis key to use as the queue_name.
server
port
queue_name
You may optionally specify a Redis db number to use. Since this module will establish the Redis connection, you may pass in a hash reference of options that are valid for the constructor of the Redis module. This can be passed in as the redis_options parameter.
db
redis_options
The claim_item method has an optional parameter here, which is the timeout in seconds it will wait for a new item. Default wait time is one second. Using a timeout > 0 sec, no additional sleep() calls are needed and items will be available to the consumer without a delay.
Steffen Mueller, <smueller@cpan.org>
Copyright (C) 2012 by Steffen Mueller
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.1 or, at your option, any later version of Perl 5 you may have available.
To install Queue::Q, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Queue::Q
CPAN shell
perl -MCPAN -e shell install Queue::Q
For more information on module installation, please visit the detailed CPAN module installation guide.