The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Queue::Q::NaiveFIFO::Redis - In-memory Redis implementation of the NaiveFIFO queue

SYNOPSIS

  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;

DESCRIPTION

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.

METHODS

All methods of Queue::Q::NaiveFIFO plus:

new

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.

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.

claim_item($timeout_secs)

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.

AUTHOR

Steffen Mueller, <smueller@cpan.org>

COPYRIGHT AND LICENSE

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.