line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Redis::Fast::List; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: tie Perl arrays to Redis lists |
4
|
|
|
|
|
|
|
# VERSION |
5
|
|
|
|
|
|
|
# AUTHORITY |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
70090
|
use strict; |
|
1
|
|
|
|
|
13
|
|
|
1
|
|
|
|
|
30
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
9
|
1
|
|
|
1
|
|
5
|
use base qw/Redis::Fast Tie::Array/; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
644
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub TIEARRAY { |
13
|
0
|
|
|
0
|
|
|
my ($class, $list, @rest) = @_; |
14
|
0
|
|
|
|
|
|
my $self = $class->new(@rest); |
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
|
|
|
$self->__set_data($list); |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
return $self; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub FETCH { |
22
|
0
|
|
|
0
|
|
|
my ($self, $index) = @_; |
23
|
0
|
|
|
|
|
|
$self->lindex($self->__get_data, $index); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub FETCHSIZE { |
27
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
28
|
0
|
|
|
|
|
|
$self->llen($self->__get_data); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub STORE { |
32
|
0
|
|
|
0
|
|
|
my ($self, $index, $value) = @_; |
33
|
0
|
|
|
|
|
|
$self->lset($self->__get_data, $index, $value); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub STORESIZE { |
37
|
0
|
|
|
0
|
|
|
my ($self, $count) = @_; |
38
|
0
|
|
|
|
|
|
$self->ltrim($self->__get_data, 0, $count); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# if $count > $self->FETCHSIZE; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub CLEAR { |
44
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
45
|
0
|
|
|
|
|
|
$self->del($self->__get_data); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub PUSH { |
49
|
0
|
|
|
0
|
|
|
my $self = shift; |
50
|
0
|
|
|
|
|
|
my $list = $self->__get_data; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
$self->rpush($list, $_) for @_; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub POP { |
56
|
0
|
|
|
0
|
|
|
my $self = shift; |
57
|
0
|
|
|
|
|
|
$self->rpop($self->__get_data); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub SHIFT { |
61
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
62
|
0
|
|
|
|
|
|
$self->lpop($self->__get_data); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub UNSHIFT { |
66
|
0
|
|
|
0
|
|
|
my $self = shift; |
67
|
0
|
|
|
|
|
|
my $list = $self->__get_data; |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
$self->lpush($list, $_) for @_; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub SPLICE { |
73
|
0
|
|
|
0
|
|
|
my ($self, $offset, $length) = @_; |
74
|
0
|
|
|
|
|
|
$self->lrange($self->__get_data, $offset, $length); |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# FIXME rest of @_ ? |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub EXTEND { |
80
|
0
|
|
|
0
|
|
|
my ($self, $count) = @_; |
81
|
0
|
|
|
|
|
|
$self->rpush($self->__get_data, '') for ($self->FETCHSIZE .. ($count - 1)); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
0
|
|
|
sub DESTROY { $_[0]->quit } |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; ## End of Redis::Fast::List |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 NAME |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Redis::Fast::List - tie Perl arrays to Redis lists |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 SYNOPSYS |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
tie @my_list, 'Redis::Fast::List', 'list_name', @Redis_new_parameters; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
$value = $my_list[$index]; |
97
|
|
|
|
|
|
|
$my_list[$index] = $value; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
$count = @my_list; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
push @my_list, 'values'; |
102
|
|
|
|
|
|
|
$value = pop @my_list; |
103
|
|
|
|
|
|
|
unshift @my_list, 'values'; |
104
|
|
|
|
|
|
|
$value = shift @my_list; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
## NOTE: fourth parameter of splice is *NOT* supported for now |
107
|
|
|
|
|
|
|
@other_list = splice(@my_list, 2, 3); |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
@my_list = (); |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=cut |