NAME
Mojo::Redis2::Transaction - Transaction guard for Mojo::Redis2
DESCRIPTION
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.
SYNOPSIS
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;
ATTRIBUTES
Mojo::Redis2::Transaction inherits all attributes from Mojo::Redis2.
METHODS
Mojo::Redis2::Transaction inherits all methods from Mojo::Redis2 and implements the following new ones.
discard
$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.
exec
$self->exec;
$self->exec(sub { my ($self, $err, $res) = @_; });
Execute all commands issued.
watch
$self = $self->watch($key, $cb);
$res = $self->watch($key);
Marks the given keys to be watched for conditional execution of a transaction.
ILLEGAL METHODS
The following methods cannot be called on an instance of Mojo::Redis2::Transaction.
blpop
brpop
brpoplpush
multi
psubscribe
publish
subscribe
COPYRIGHT AND LICENSE
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.
AUTHOR
Jan Henning Thorsen - jhthorsen@cpan.org