| 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 | 2 | $Redis::List::VERSION = '2.000'; | |
| 12 | # ABSTRACT: tie Perl arrays to Redis lists | ||
| 13 | # VERSION | ||
| 14 | # AUTHORITY | ||
| 15 | |||
| 16 | 2 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 17 | 2 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 18 | 2 | ▶ | use base qw/Redis Tie::Array/; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 19 | |||
| 20 | |||
| 21 | 0 | ▶ | sub TIEARRAY { |
|
Subroutine
TIEARRAY: not called CC=1 SCAR=6.9
| |||
| 22 | 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 | 0 | ▶ | sub FETCH { |
|
Subroutine
FETCH: not called CC=1 SCAR=6.9
| |||
| 31 | 0 | my ($self, $index) = @_; | |
| 32 | 0 | $self->lindex($self->{list}, $index); | |
| 33 | } | ||
| 34 | |||
| 35 | 0 | ▶ | sub FETCHSIZE { |
|
Subroutine
FETCHSIZE: not called CC=1 SCAR=6.9
| |||
| 36 | 0 | my ($self) = @_; | |
| 37 | 0 | $self->llen($self->{list}); | |
| 38 | } | ||
| 39 | |||
| 40 | 0 | ▶ | sub STORE { |
|
Subroutine
STORE: not called CC=1 SCAR=6.9
| |||
| 41 | 0 | my ($self, $index, $value) = @_; | |
| 42 | 0 | $self->lset($self->{list}, $index, $value); | |
| 43 | } | ||
| 44 | |||
| 45 | 0 | ▶ | sub STORESIZE { |
|
Subroutine
STORESIZE: not called CC=1 SCAR=6.9
| |||
| 46 | 0 | my ($self, $count) = @_; | |
| 47 | 0 | $self->ltrim($self->{list}, 0, $count); | |
| 48 | |||
| 49 | # if $count > $self->FETCHSIZE; | ||
| 50 | } | ||
| 51 | |||
| 52 | 0 | ▶ | sub CLEAR { |
|
Subroutine
CLEAR: not called CC=1 SCAR=6.9
| |||
| 53 | 0 | my ($self) = @_; | |
| 54 | 0 | $self->del($self->{list}); | |
| 55 | } | ||
| 56 | |||
| 57 | 0 | ▶ | sub PUSH { |
|
Subroutine
PUSH: not called CC=2 SCAR=17.9
| |||
| 58 | 0 | my $self = shift; | |
| 59 | 0 | my $list = $self->{list}; | |
| 60 | |||
| 61 | 0 | $self->rpush($list, $_) for @_; | |
| 62 | } | ||
| 63 | |||
| 64 | 0 | ▶ | sub POP { |
|
Subroutine
POP: not called CC=1 SCAR=6.9
| |||
| 65 | 0 | my $self = shift; | |
| 66 | 0 | $self->rpop($self->{list}); | |
| 67 | } | ||
| 68 | |||
| 69 | 0 | ▶ | sub SHIFT { |
|
Subroutine
SHIFT: not called CC=1 SCAR=6.9
| |||
| 70 | 0 | my ($self) = @_; | |
| 71 | 0 | $self->lpop($self->{list}); | |
| 72 | } | ||
| 73 | |||
| 74 | 0 | ▶ | sub UNSHIFT { |
|
Subroutine
UNSHIFT: not called CC=2 SCAR=17.9
| |||
| 75 | 0 | my $self = shift; | |
| 76 | 0 | my $list = $self->{list}; | |
| 77 | |||
| 78 | 0 | $self->lpush($list, $_) for @_; | |
| 79 | } | ||
| 80 | |||
| 81 | 0 | ▶ | sub SPLICE { |
|
Subroutine
SPLICE: not called CC=1 SCAR=6.9
| |||
| 82 | 0 | my ($self, $offset, $length) = @_; | |
| 83 | 0 | $self->lrange($self->{list}, $offset, $length); | |
| 84 | |||
| 85 | # FIXME rest of @_ ? | ||
| 86 | } | ||
| 87 | |||
| 88 | 0 | ▶ | sub EXTEND { |
|
Subroutine
EXTEND: not called CC=2 SCAR=17.9
| |||
| 89 | 0 | my ($self, $count) = @_; | |
| 90 | 0 | $self->rpush($self->{list}, '') for ($self->FETCHSIZE .. ($count - 1)); | |
| 91 | } | ||
| 92 | |||
| 93 | 0 | ▶ | sub DESTROY { $_[0]->quit } |
|
Subroutine
DESTROY: not called CC=1 SCAR=6.9
| |||
| 94 | |||
| 95 | 2 | 1; ## End of Redis::List | |
| 96 | |||
| 97 | __END__ | ||