Redis/Hash.pm

filter: Statementstmt 35.9% 14 / 39 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 33.3% 4 / 12 Podpod n/a totaltotal 31.5% 18 / 57 CC 5 SCAR 15.3
CC
5
Cov
31%
NEXTKEY
12.0
TIEHASH
6.0
CLEAR
6.0
CRAP 4.6
« Redis/Sentinel.pm ↑ Summary Redis/List.pm »
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::Hash;
11 2 $Redis::Hash::VERSION = '2.000';
12 # ABSTRACT: tie Perl hashes to Redis hashes
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 Tie::Hash;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 2 ▶use base qw/Redis Tie::StdHash/;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21  
22 0 ▶sub TIEHASH {
Subroutine TIEHASH: not called CC=2 SCAR=17.9
23 0 my ($class, $prefix, @rest) = @_;
24 0 my $self = $class->new(@rest);
25  
26 0 ▶ $self->{prefix} = $prefix ? "$prefix:" : '';
Branch: 1 branch
BranchTrueFalseTotal
$prefix ? : 0 0 0
27  
28 0 return $self;
29 }
30  
31 0 ▶sub STORE {
Subroutine STORE: not called CC=1 SCAR=6.9
32 0 my ($self, $key, $value) = @_;
33 0 $self->set($self->{prefix} . $key, $value);
34 }
35  
36 0 ▶sub FETCH {
Subroutine FETCH: not called CC=1 SCAR=6.9
37 0 my ($self, $key) = @_;
38 0 $self->get($self->{prefix} . $key);
39 }
40  
41 0 ▶sub FIRSTKEY {
Subroutine FIRSTKEY: not called CC=1 SCAR=6.9
42 0 my $self = shift;
43 0 $self->{prefix_keys} = [$self->keys($self->{prefix} . '*')];
44 0 $self->NEXTKEY;
45 }
46  
47 0 ▶sub NEXTKEY {
Subroutine NEXTKEY: not called CC=3 SCAR=24.8
48 0 my $self = shift;
49  
50 0 my $key = shift @{ $self->{prefix_keys} };
51 0 ▶ return unless defined $key;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $key 0 0 0
52  
53 0 my $p = $self->{prefix};
54 0 ▶ $key =~ s/^$p// if $p;
Branch: 1 branch
BranchTrueFalseTotal
if $p 0 0 0
55 0 return $key;
56 }
57  
58 0 ▶sub EXISTS {
Subroutine EXISTS: not called CC=1 SCAR=6.9
59 0 my ($self, $key) = @_;
60 0 $self->exists($self->{prefix} . $key);
61 }
62  
63 0 ▶sub DELETE {
Subroutine DELETE: not called CC=1 SCAR=6.9
64 0 my ($self, $key) = @_;
65 0 $self->del($self->{prefix} . $key);
66 }
67  
68 0 ▶sub CLEAR {
Subroutine CLEAR: not called CC=2 SCAR=17.9
69 0 my ($self) = @_;
70 0 $self->del($_) for $self->keys($self->{prefix} . '*');
71 0 $self->{prefix_keys} = [];
72 }
73  
74  
75 2 1; ## End of Redis::Hash
76  
77 __END__
« Redis/Sentinel.pm ↑ Summary Redis/List.pm »