Mojo::Redis2::Transaction - Transaction guard for Mojo::Redis2
Mojo::Redis2::Transaction is an object for handling transactions started by "multi" in Mojo::Redis2.
All transactions objects will be kept isolated having its own connection to the database. One object can also be re-used: Calling a Redis method after "exec" or "discard" will result in sending the "MULTI" command to the Redis server again.
"discard" is automatically called when an instance of Mojo::Redis2::Transaction goes out of scope.
See also http://redis.io/topics/transactions.
use Mojo::Redis2; my $redis = Mojo::Redis2->new; my $txn = $redis->multi; $txn->set(foo => 42); $txn->exec; # the same object (and connection to database) can be re-used $txn->incr('foo'); $txn->discard;
Mojo::Redis2::Transaction inherits all attributes from Mojo::Redis2.
Mojo::Redis2::Transaction inherits all methods from Mojo::Redis2 and implements the following new ones.
$self->discard; $self->discard(sub { my ($self, $err, $res) = @_; });
Discard all commands issued. This method is called automatically on DESTROY, unless "exec" was called first.
$self->exec; $self->exec(sub { my ($self, $err, $res) = @_; });
Execute all commands issued.
$self = $self->watch($key, $cb); $res = $self->watch($key);
Marks the given keys to be watched for conditional execution of a transaction.
The following methods cannot be called on an instance of Mojo::Redis2::Transaction.
blpop
brpop
brpoplpush
multi
psubscribe
publish
subscribe
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.