Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Resque client in Perl
package Resque;
use Any::Moose;
use Redis;
use JSON;
has server => (is => 'rw', isa => 'Str', default => 'localhost:6379');
has redis => (is => 'rw', isa => 'Redis', lazy_build => 1);
sub _build_redis {
my $self = shift;
Redis->new(server => $self->server);
}
sub push {
my($self, $queue, $obj) = @_;
my $key = "resque:queue:$queue";
$self->redis->rpush($key, JSON::encode_json($obj));
}
sub pop {
my($self, $queue, $obj) = @_;
my $key = "resque:queue:$queue";
JSON::decode_json( $self->redis->lpop($key) );
}
my $r = Resque->new;
$r->push('default', { class => 'ShellJob', args => [ 'which', 'cat' ] });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment