Mojo::Redis2::Bulk - Mojo::Redis2 bulk operations
Mojo::Redis2::Bulk allow many Mojo::Redis2 operations to be grouped into one serialized operation. This can help you avoid crazy many callback arguments.
use Mojo::Redis2; my $redis = Mojo::Redis2->new; my $bulk = $redis->bulk; $res = $bulk->set(foo => 123)->get("foo")->execute; Mojo::IOLoop->delay( sub { my ($delay) = @_; $bulk->set(foo => 123)->get("foo")->execute($delay->begin); }, sub { my ($delay, $err, $res) = @_; $self->render(json => { err => $err->compact->join('. '), res => $res, }); }, );
In both the sync and async examples above, $res will contain on success:
$res
[ "OK", 123, ];
$err on the other hand will be a Mojo::Collection object with all one element for each error message.
$err
In addition to the methods listed in this module, you can call these Redis methods on $self:
$self
append, echo, decr, decrby, del, exists, expire, expireat, get, getbit, getrange, getset, hdel, hexists, hget, hgetall, hincrby, hkeys, hlen, hmget, hmset, hset, hsetnx, hvals, incr, incrby, keys, lindex, linsert, llen, lpop, lpush, lpushx, lrange, lrem, lset, ltrim, mget, move, mset, msetnx, persist, ping, publish, randomkey, rename, renamenx, rpop, rpoplpush, rpush, rpushx, sadd, scard, sdiff, sdiffstore, set, setbit, setex, setnx, setrange, sinter, sinterstore, sismember, smembers, smove, sort, spop, srandmember, srem, strlen, sunion, sunionstore, ttl, type, zadd, zcard, zcount, zincrby, zinterstore, zrange, zrangebyscore, zrank, zrem, zremrangebyrank, zremrangebyscore, zrevrange, zrevrangebyscore, zrevrank, zscore and zunionstore.
$res = $self->execute; $self = $self->execute(sub { my ($self, $err, $res) = @_; });
Will execute all the queued Redis operations.
Copyright (C) 2014, Jan Henning Thorsen
This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.
Jan Henning Thorsen - jhthorsen@cpan.org
jhthorsen@cpan.org
To install Mojo::Redis2, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojo::Redis2
CPAN shell
perl -MCPAN -e shell install Mojo::Redis2
For more information on module installation, please visit the detailed CPAN module installation guide.