RWDE/DB/MemcachedRegistry.pm untested

filter: Statementstmt 0.0% 0 / 54 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 14 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 82 CC 5 SCAR 15.2
CC
5
Cov
0%
flush_all
12.0
get_instance
6.0
get_memh
6.0
CRAP 4.6
1 package RWDE::DB::MemcachedRegistry;
2  
3 use strict;
4 use warnings;
5  
6 use Error qw(:try);
7  
8 use RWDE::Configuration;
9 use RWDE::Exceptions;
10 use RWDE::DB::MemcachedAdapter;
11  
12 use base qw( RWDE::Singleton);
13  
14 my $unique_instance;
15  
16 use vars qw($VERSION);
17 $VERSION = sprintf "%d", q$Revision: 508 $ =~ /(\d+)/;
18  
19 sub get_instance {
20 my ($self, $params) = @_;
21  
22 if (ref $unique_instance ne $self) {
23 $unique_instance = $self->new;
24 }
25  
26 return $unique_instance;
27 }
28  
29 sub initialize {
30 my ($self, $params) = @_;
31  
32 return ();
33 }
34  
35 sub _connect {
36 my ($self, $params) = @_;
37  
38 $self->{memh} = new RWDE::DB::MemcachedAdapter { server => RWDE::Configuration->CACHE . ":11211" };
39  
40 return ();
41 }
42  
43 sub get_memh {
44 my ($self, $params) = @_;
45  
46 my $memcached_registry = $self->get_instance();
47  
48 unless (defined $memcached_registry->{memh}) {
49 $memcached_registry->_connect();
50 }
51  
52 return $memcached_registry->{memh};
53 }
54  
55 sub disconnect_all {
56 my ($self, $params) = @_;
57  
58 my $memcached_registry = $self->get_instance();
59  
60 $memcached_registry->{memh}->disconnect_all();
61  
62 return ();
63 }
64  
65 sub flush_all {
66 my ($self, $params) = @_;
67  
68 my $memcached_registry = $self->get_instance();
69  
70 my $memh = RWDE::DB::MemcachedRegistry->get_memh();
71  
72 if ($memh) {
73 print "Flushing";
74 if ($memh->flush_all()) {
75 print ": success! \n";
76 }
77  
78 else {
79 print ": failed! \n";
80 }
81  
82 }
83 return ();
84 }
85  
86 1;