line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Redis::AOF::Tail::File; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
92891
|
use 5.008008; |
|
4
|
|
|
|
|
15
|
|
|
4
|
|
|
|
|
251
|
|
4
|
4
|
|
|
4
|
|
23
|
use strict; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
231
|
|
5
|
4
|
|
|
4
|
|
24
|
use warnings; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
694
|
|
6
|
4
|
|
|
4
|
|
2489
|
use File::Tail::Lite; |
|
4
|
|
|
|
|
2558
|
|
|
4
|
|
|
|
|
1810
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
5
|
|
|
5
|
1
|
1296
|
my $pkg = shift; |
12
|
5
|
|
|
|
|
19
|
my $self = {@_}; |
13
|
5
|
|
|
|
|
11
|
bless $self, $pkg; |
14
|
|
|
|
|
|
|
|
15
|
5
|
50
|
|
|
|
147
|
return 0 unless -e $self->{aof_filename}; |
16
|
|
|
|
|
|
|
|
17
|
5
|
|
|
|
|
9
|
$self->{ARRAY_REDIS_AOF} = (); |
18
|
|
|
|
|
|
|
|
19
|
5
|
100
|
|
|
|
17
|
if ( $self->{seekpos} ) { |
20
|
4
|
|
|
|
|
33
|
$self->{FILE_TAIL_FH} = new File::Tail::Lite( |
21
|
|
|
|
|
|
|
filename => $self->{aof_filename}, |
22
|
|
|
|
|
|
|
seekpos => $self->{seekpos} |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
else { |
26
|
1
|
|
|
|
|
10
|
$self->{FILE_TAIL_FH} = $self->{FILE_TAIL_FH} = new File::Tail::Lite( |
27
|
|
|
|
|
|
|
filename => $self->{aof_filename}, |
28
|
|
|
|
|
|
|
seekpos => 'start' |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
} |
31
|
5
|
|
|
|
|
357
|
return $self; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub read_command { |
35
|
9
|
|
|
9
|
1
|
1677
|
my $self = shift; |
36
|
9
|
50
|
|
|
|
30
|
return 0 unless $self->{FILE_TAIL_FH}; |
37
|
|
|
|
|
|
|
|
38
|
9
|
|
|
|
|
31
|
while ( my ( $pos, $line ) = $self->{FILE_TAIL_FH}->readline() ) { |
39
|
70
|
|
|
|
|
1536
|
$line =~ s/\s//g; |
40
|
70
|
|
|
|
|
65
|
push @{ $self->{ARRAY_REDIS_AOF} }, $line; |
|
70
|
|
|
|
|
100
|
|
41
|
70
|
|
100
|
|
|
67
|
while ( defined ${ $self->{ARRAY_REDIS_AOF} }[0] |
|
79
|
|
|
|
|
147
|
|
|
70
|
|
|
|
|
237
|
|
42
|
|
|
|
|
|
|
and ${ $self->{ARRAY_REDIS_AOF} }[0] !~ /^\*\d/ ) |
43
|
|
|
|
|
|
|
{ |
44
|
9
|
|
|
|
|
7
|
shift @{ $self->{ARRAY_REDIS_AOF} }; |
|
9
|
|
|
|
|
16
|
|
45
|
|
|
|
|
|
|
} |
46
|
61
|
|
|
|
|
139
|
my ($cmd_num) = ${ $self->{ARRAY_REDIS_AOF} }[0] =~ /^\*(\d{1,2})/ |
|
70
|
|
|
|
|
104
|
|
47
|
70
|
100
|
|
|
|
56
|
if ${ $self->{ARRAY_REDIS_AOF} }[0]; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
next |
50
|
61
|
|
|
|
|
280
|
if ( !$cmd_num |
51
|
70
|
100
|
100
|
|
|
195
|
or scalar @{ $self->{ARRAY_REDIS_AOF} } < $cmd_num * 2 + 1 ) |
52
|
|
|
|
|
|
|
; # Wait for the complete command |
53
|
|
|
|
|
|
|
|
54
|
9
|
|
|
|
|
11
|
shift @{ $self->{ARRAY_REDIS_AOF} }; |
|
9
|
|
|
|
|
12
|
|
55
|
9
|
|
|
|
|
34
|
my $cmd = ""; |
56
|
9
|
|
|
|
|
17
|
for ( 1 .. $cmd_num ) { |
57
|
26
|
|
|
|
|
19
|
shift @{ $self->{ARRAY_REDIS_AOF} }; |
|
26
|
|
|
|
|
25
|
|
58
|
26
|
|
|
|
|
22
|
$cmd .= shift @{ $self->{ARRAY_REDIS_AOF} }; |
|
26
|
|
|
|
|
24
|
|
59
|
26
|
|
|
|
|
30
|
$cmd .= ' '; |
60
|
|
|
|
|
|
|
} |
61
|
9
|
|
|
|
|
19
|
$cmd = substr( $cmd, 0, -1 ); |
62
|
9
|
|
|
|
|
22
|
return ( $pos, $cmd ); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
67
|
|
|
|
|
|
|
__END__ |