| 1 | package Cache::FastMmap::Tie; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 5 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 5 | ▶ | use v5.8.1; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 5 | our $VERSION = '0.03'; | |||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 5 | ▶ | use base 'Cache::FastMmap'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 5 | ▶ | use Class::Inspector; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | 5 | ▶ | use Best [ [ qw/YAML::XS YAML::Syck YAML/ ], qw/LoadFile/ ]; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 4 | ▶ | sub TIEHASH{ | ||||||||||||||||||
|
Subroutine
TIEHASH: called CC=6 SCAR=18.2
| |||||||||||||||||||||
| 12 | 4 | my $class = shift; | |||||||||||||||||||
| 13 | 4 | my ($params_hash) = @_; | |||||||||||||||||||
| 14 | 4 | my $self; | |||||||||||||||||||
| 15 | 4 | ▶ | if (ref $params_hash eq 'HASH') { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 16 | 1 | $params_hash = shift @_; | |||||||||||||||||||
| 17 | 1 | ▶ | if (my $yaml_file = delete $params_hash->{yaml_file}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 18 | 1 | ▶ | $params_hash = LoadFile("$yaml_file") or | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 19 | die "Can't open `$yaml_file':$@ ",__LINE__; | ||||||||||||||||||||
| 20 | } | ||||||||||||||||||||
| 21 | 1 | ▶ | $self = $class->new(%{$params_hash}) unless @_; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 22 | } | ||||||||||||||||||||
| 23 | 4 | ▶ | $self ||= $class->new(@_); | ||||||||||||||||||
|
Condition66%2/3
$self ||= $class->new(@_)
MC/DC0%0/2
$self ||= $class->new(@_)
$self
$class->new(@_)
Truth table66%2/3
A ||= B
A= $selfB= $class->new(@_)
| |||||||||||||||||||||
| 24 | 4 | $self->{_tie_var} = {}; | |||||||||||||||||||
| 25 | 4 | return $self; | |||||||||||||||||||
| 26 | } | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 8 | ▶ | sub STORE { shift->set(@_) } # ( Key => Value ) | ||||||||||||||||||
|
Subroutine
STORE: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | 14 | ▶ | sub FETCH { shift->get(@_) } # ( Key ) | ||||||||||||||||||
|
Subroutine
FETCH: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | 0 | ▶ | sub DELETE{ shift->remove(@_) } # ( Key ) | ||||||||||||||||||
|
Subroutine
DELETE: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | 0 | ▶ | sub CLEAR { shift->clear } | ||||||||||||||||||
|
Subroutine
CLEAR: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 9 | ▶ | sub EXISTS { # ( Key ) | ||||||||||||||||||
|
Subroutine
EXISTS: called CC=3 SCAR=11.1
| |||||||||||||||||||||
| 37 | 9 | my $self = shift; | |||||||||||||||||||
| 38 | 9 | $self->purge; | |||||||||||||||||||
| 39 | 9 | for ($self->get_keys(0)){ | |||||||||||||||||||
| 40 | 5 | ▶ | $_ eq $_[0] and return 1; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 41 | } | ||||||||||||||||||||
| 42 | 4 | return ; | |||||||||||||||||||
| 43 | } | ||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | 12 | ▶ | sub FIRSTKEY { | ||||||||||||||||||
|
Subroutine
FIRSTKEY: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 46 | 12 | my $self = shift; | |||||||||||||||||||
| 47 | 12 | $self->purge; | |||||||||||||||||||
| 48 | 12 | @{$self->{_tie_var}->{get_keys_0}} = $self->get_keys(0); | |||||||||||||||||||
| 49 | 12 | shift @{$self->{_tie_var}->{get_keys_0}}; | |||||||||||||||||||
| 50 | } | ||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | 16 | ▶ | sub NEXTKEY { # ( prevKey ) | ||||||||||||||||||
|
Subroutine
NEXTKEY: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 53 | 16 | my $self = shift; | |||||||||||||||||||
| 54 | 16 | shift @{$self->{_tie_var}->{get_keys_0}}; | |||||||||||||||||||
| 55 | } | ||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | #sub DESTROY {} | ||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | 5 | 1; | |||||||||||||||||||
| 60 | __END__ | ||||||||||||||||||||