line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Redis::AOF::Tail::File; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
125791
|
use 5.008008; |
|
4
|
|
|
|
|
45
|
|
|
4
|
|
|
|
|
186
|
|
4
|
4
|
|
|
4
|
|
25
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
196
|
|
5
|
4
|
|
|
4
|
|
24
|
use warnings; |
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
152
|
|
6
|
4
|
|
|
4
|
|
2809
|
use File::Tail::Lite; |
|
4
|
|
|
|
|
2491
|
|
|
4
|
|
|
|
|
2412
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
5
|
|
|
5
|
1
|
1854
|
my $pkg = shift; |
12
|
5
|
|
|
|
|
24
|
my $self = {@_}; |
13
|
5
|
|
|
|
|
18
|
bless $self, $pkg; |
14
|
|
|
|
|
|
|
|
15
|
5
|
50
|
|
|
|
177
|
return 0 unless -e $self->{aof_filename}; |
16
|
|
|
|
|
|
|
|
17
|
5
|
|
|
|
|
19
|
$self->{ARRAY_REDIS_AOF} = (); |
18
|
|
|
|
|
|
|
|
19
|
5
|
100
|
|
|
|
24
|
if ( $self->{seekpos} ) { |
20
|
4
|
|
|
|
|
40
|
$self->{FILE_TAIL_FH} = new File::Tail::Lite( |
21
|
|
|
|
|
|
|
filename => $self->{aof_filename}, |
22
|
|
|
|
|
|
|
seekpos => $self->{seekpos} |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
else { |
26
|
1
|
|
|
|
|
12
|
$self->{FILE_TAIL_FH} = $self->{FILE_TAIL_FH} = new File::Tail::Lite( |
27
|
|
|
|
|
|
|
filename => $self->{aof_filename}, |
28
|
|
|
|
|
|
|
seekpos => 'start' |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
} |
31
|
5
|
|
|
|
|
467
|
return $self; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub read_command { |
35
|
9
|
|
|
9
|
1
|
2176
|
my $self = shift; |
36
|
9
|
50
|
|
|
|
37
|
return 0 unless $self->{FILE_TAIL_FH}; |
37
|
|
|
|
|
|
|
|
38
|
9
|
|
|
|
|
45
|
while ( my ( $pos, $line ) = $self->{FILE_TAIL_FH}->readline() ) { |
39
|
70
|
|
|
|
|
2508
|
$line =~ s/\s//g; |
40
|
70
|
100
|
|
|
|
184
|
next if length($line) == 0; |
41
|
69
|
|
|
|
|
67
|
push @{ $self->{ARRAY_REDIS_AOF} }, $line; |
|
69
|
|
|
|
|
171
|
|
42
|
69
|
|
100
|
|
|
82
|
while ( defined ${ $self->{ARRAY_REDIS_AOF} }[0] |
|
77
|
|
|
|
|
197
|
|
|
69
|
|
|
|
|
360
|
|
43
|
|
|
|
|
|
|
and ${ $self->{ARRAY_REDIS_AOF} }[0] !~ /^\*\d/ ) |
44
|
|
|
|
|
|
|
{ |
45
|
8
|
|
|
|
|
10
|
shift @{ $self->{ARRAY_REDIS_AOF} }; |
|
8
|
|
|
|
|
21
|
|
46
|
|
|
|
|
|
|
} |
47
|
61
|
|
|
|
|
257
|
my ($cmd_num) = ${ $self->{ARRAY_REDIS_AOF} }[0] =~ /^\*(\d{1,2})/ |
|
69
|
|
|
|
|
162
|
|
48
|
69
|
100
|
|
|
|
77
|
if ${ $self->{ARRAY_REDIS_AOF} }[0]; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
next |
51
|
61
|
|
|
|
|
433
|
if ( !$cmd_num |
52
|
69
|
100
|
100
|
|
|
213
|
or scalar @{ $self->{ARRAY_REDIS_AOF} } < $cmd_num * 2 + 1 ) |
53
|
|
|
|
|
|
|
; # Wait for the complete command |
54
|
|
|
|
|
|
|
|
55
|
9
|
|
|
|
|
26
|
shift @{ $self->{ARRAY_REDIS_AOF} }; |
|
9
|
|
|
|
|
17
|
|
56
|
9
|
|
|
|
|
16
|
my $cmd = ""; |
57
|
9
|
|
|
|
|
23
|
for ( 1 .. $cmd_num ) { |
58
|
26
|
|
|
|
|
24
|
shift @{ $self->{ARRAY_REDIS_AOF} }; |
|
26
|
|
|
|
|
37
|
|
59
|
26
|
|
|
|
|
32
|
$cmd .= shift @{ $self->{ARRAY_REDIS_AOF} }; |
|
26
|
|
|
|
|
40
|
|
60
|
26
|
|
|
|
|
46
|
$cmd .= ' '; |
61
|
|
|
|
|
|
|
} |
62
|
9
|
|
|
|
|
26
|
$cmd = substr( $cmd, 0, -1 ); |
63
|
9
|
|
|
|
|
36
|
return ( $pos, $cmd ); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
68
|
|
|
|
|
|
|
__END__ |