blib/lib/MYDan/Collector/Stat/Cache.pm untested

filter: Statementstmt 0.0% 0 / 35 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 55 CC 4 SCAR 21.5
CC
4
Cov
0%
co
20.0
BEGIN
2.0
BEGIN
2.0
CRAP 8.5
1 package MYDan::Collector::Stat::Cache;
2  
3 use strict;
4 use warnings;
5 use Carp;
6 use POSIX;
7  
8 use MYDan::Bone::Redis;
9 use Data::Dumper;
10  
11 use YAML::XS;
12  
13 sub co
14 {
15 my ( $this, %cache, @stat ) = shift;
16  
17 map{ $cache{$1} = 1 if $_ =~ /^\{CACHE:([\w:_]+)\}\{/ }@_;
18 my $redis = MYDan::Bone::Redis->new("read");
19 my @keys = keys %cache;
20 my @mesg = $redis->mget( @keys );
21  
22 for( 0 .. @keys -1 )
23 {
24 next unless $mesg[$_];
25 my $data = eval{ YAML::XS::Load $mesg[$_] };
26 next unless ref $data eq 'ARRAY' && ref $data->[0] eq 'ARRAY';
27 $data->[0][0] = "CACHE:$keys[$_]";
28 push @stat, $data;
29 }
30  
31 return @stat;
32 }
33  
34 1;