line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Tie::Redis::List; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
6
|
|
|
6
|
|
2420
|
$Tie::Redis::List::VERSION = '0.22_1'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
# ABSTRACT: Connect a Redis list to a Perl array |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub TIEARRAY { |
8
|
0
|
|
|
0
|
|
|
my($class, %args) = @_; |
9
|
0
|
|
|
|
|
|
bless \%args, $class; |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub _cmd { |
13
|
0
|
|
|
0
|
|
|
my($self, $cmd, @args) = @_; |
14
|
0
|
|
|
|
|
|
return $self->{redis}->_cmd($cmd, $self->{key}, @args); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub FETCH { |
18
|
0
|
|
|
0
|
|
|
my($self, $i) = @_; |
19
|
0
|
|
|
|
|
|
$self->_cmd(lindex => $i); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub FETCHSIZE { |
23
|
0
|
|
|
0
|
|
|
my($self) = @_; |
24
|
0
|
|
|
|
|
|
$self->_cmd("llen"); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub PUSH { |
28
|
0
|
|
|
0
|
|
|
my($self, @elements) = @_; |
29
|
0
|
|
|
|
|
|
$self->_cmd(rpush => $_) for @elements; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
0
|
|
|
sub EXTEND { |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub STORE { |
36
|
0
|
|
|
0
|
|
|
my($self, $index, $value) = @_; |
37
|
0
|
|
|
|
|
|
my $len = $self->_cmd("llen"); |
38
|
0
|
0
|
|
|
|
|
if($index >= $len) { |
39
|
0
|
|
|
|
|
|
while($index > $len) { |
40
|
0
|
|
|
|
|
|
$self->_cmd(rpush => ""); |
41
|
0
|
|
|
|
|
|
$len++; |
42
|
|
|
|
|
|
|
} |
43
|
0
|
|
|
|
|
|
$self->_cmd(rpush => $value); |
44
|
|
|
|
|
|
|
} else { |
45
|
0
|
|
|
|
|
|
$self->_cmd(lset => $index, $value); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub POP { |
50
|
0
|
|
|
0
|
|
|
my($self) = @_; |
51
|
0
|
|
|
|
|
|
$self->_cmd("rpop"); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub SHIFT { |
55
|
0
|
|
|
0
|
|
|
my($self) = @_; |
56
|
0
|
|
|
|
|
|
$self->_cmd("lpop"); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub UNSHIFT { |
60
|
0
|
|
|
0
|
|
|
my($self, $value) = @_; |
61
|
0
|
|
|
|
|
|
$self->_cmd(lpush => $value); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub SPLICE { |
65
|
0
|
|
|
0
|
|
|
my($self, $offset, $length, @list) = @_; |
66
|
|
|
|
|
|
|
|
67
|
0
|
0
|
|
|
|
|
my @items = $length == 0 ? () : $self->_cmd(lrange => $offset, $length - 1); |
68
|
0
|
0
|
|
|
|
|
$self->_cmd(ltrim => $offset, $offset + $length - 1) if $length > 0; |
69
|
|
|
|
|
|
|
# XXX |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub CLEAR { |
73
|
0
|
|
|
0
|
|
|
my($self) = @_; |
74
|
0
|
|
|
|
|
|
$self->_cmd("del"); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
__END__ |