line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# This file is part of Redis |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# This software is Copyright (c) 2015 by Pedro Melo, Damien Krotkine. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This is free software, licensed under: |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# The Artistic License 2.0 (GPL Compatible) |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
package Redis::List; |
11
|
|
|
|
|
|
|
$Redis::List::VERSION = '2.000'; |
12
|
|
|
|
|
|
|
# ABSTRACT: tie Perl arrays to Redis lists |
13
|
|
|
|
|
|
|
# VERSION |
14
|
|
|
|
|
|
|
# AUTHORITY |
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
69663
|
use strict; |
|
1
|
|
|
|
|
13
|
|
|
1
|
|
|
|
|
28
|
|
17
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
18
|
1
|
|
|
1
|
|
4
|
use base qw/Redis Tie::Array/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
734
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub TIEARRAY { |
22
|
0
|
|
|
0
|
|
|
my ($class, $list, @rest) = @_; |
23
|
0
|
|
|
|
|
|
my $self = $class->new(@rest); |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
$self->{list} = $list; |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
return $self; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub FETCH { |
31
|
0
|
|
|
0
|
|
|
my ($self, $index) = @_; |
32
|
0
|
|
|
|
|
|
$self->lindex($self->{list}, $index); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub FETCHSIZE { |
36
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
37
|
0
|
|
|
|
|
|
$self->llen($self->{list}); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub STORE { |
41
|
0
|
|
|
0
|
|
|
my ($self, $index, $value) = @_; |
42
|
0
|
|
|
|
|
|
$self->lset($self->{list}, $index, $value); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub STORESIZE { |
46
|
0
|
|
|
0
|
|
|
my ($self, $count) = @_; |
47
|
0
|
|
|
|
|
|
$self->ltrim($self->{list}, 0, $count); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# if $count > $self->FETCHSIZE; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub CLEAR { |
53
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
54
|
0
|
|
|
|
|
|
$self->del($self->{list}); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub PUSH { |
58
|
0
|
|
|
0
|
|
|
my $self = shift; |
59
|
0
|
|
|
|
|
|
my $list = $self->{list}; |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
$self->rpush($list, $_) for @_; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub POP { |
65
|
0
|
|
|
0
|
|
|
my $self = shift; |
66
|
0
|
|
|
|
|
|
$self->rpop($self->{list}); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub SHIFT { |
70
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
71
|
0
|
|
|
|
|
|
$self->lpop($self->{list}); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub UNSHIFT { |
75
|
0
|
|
|
0
|
|
|
my $self = shift; |
76
|
0
|
|
|
|
|
|
my $list = $self->{list}; |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
$self->lpush($list, $_) for @_; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub SPLICE { |
82
|
0
|
|
|
0
|
|
|
my ($self, $offset, $length) = @_; |
83
|
0
|
|
|
|
|
|
$self->lrange($self->{list}, $offset, $length); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# FIXME rest of @_ ? |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub EXTEND { |
89
|
0
|
|
|
0
|
|
|
my ($self, $count) = @_; |
90
|
0
|
|
|
|
|
|
$self->rpush($self->{list}, '') for ($self->FETCHSIZE .. ($count - 1)); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
0
|
|
|
0
|
|
|
sub DESTROY { $_[0]->quit } |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; ## End of Redis::List |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
__END__ |