| 1 | package Async::Redis::Transaction; | ||||||||||
| 2 | |||||||||||
| 3 | 91 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 91 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 91 | ▶ | use 5.018; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 91 | ▶ | use Future::AsyncAwait; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 10 | 0 | my ($class, %args) = @_; | |||||||||
| 11 | return bless { | ||||||||||
| 12 | redis => $args{redis}, | ||||||||||
| 13 | 0 | commands => [], | |||||||||
| 14 | }, $class; | ||||||||||
| 15 | } | ||||||||||
| 16 | |||||||||||
| 17 | # Queue a command for execution in the transaction | ||||||||||
| 18 | # Returns a placeholder (the actual result comes from EXEC) | ||||||||||
| 19 | 0 | ▶ | sub _queue_command { | ||||||||
|
Subroutine
_queue_command: not called CC=1 SCAR=6.9
| |||||||||||
| 20 | 0 | my ($self, $cmd, @args) = @_; | |||||||||
| 21 | 0 | push @{$self->{commands}}, [$cmd, @args]; | |||||||||
| 22 | 0 | return scalar(@{$self->{commands}}) - 1; # index of this command | |||||||||
| 23 | } | ||||||||||
| 24 | |||||||||||
| 25 | # Generate AUTOLOAD to capture any command call | ||||||||||
| 26 | 91 | our $AUTOLOAD; | |||||||||
| 27 | |||||||||||
| 28 | 0 | ▶ | sub AUTOLOAD { | ||||||||
|
Subroutine
AUTOLOAD: not called CC=2 SCAR=17.9
| |||||||||||
| 29 | 0 | my $self = shift; | |||||||||
| 30 | 0 | my $cmd = $AUTOLOAD; | |||||||||
| 31 | 0 | $cmd =~ s/.*:://; | |||||||||
| 32 | 0 | ▶ | return if $cmd eq 'DESTROY'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | |||||||||||
| 34 | # Queue the command | ||||||||||
| 35 | 0 | $self->_queue_command(uc($cmd), @_); | |||||||||
| 36 | 0 | return; # Transaction commands don't return Futures individually | |||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | # Allow explicit command() calls too | ||||||||||
| 40 | 0 | ▶ | sub command { | ||||||||
|
Subroutine
command: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 41 | 0 | my ($self, $cmd, @args) = @_; | |||||||||
| 42 | 0 | $self->_queue_command($cmd, @args); | |||||||||
| 43 | 0 | return; | |||||||||
| 44 | } | ||||||||||
| 45 | |||||||||||
| 46 | 0 | ▶ | sub commands { @{shift->{commands}} } | ||||||||
|
Subroutine
commands: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 47 | |||||||||||
| 48 | 91 | 1; | |||||||||
| 49 | |||||||||||
| 50 | __END__ | ||||||||||