File Coverage

blib/lib/Webqq/Client/Cache.pm
Criterion Covered Total %
statement 0 19 0.0
branch 0 6 0.0
condition n/a
subroutine 0 4 0.0
pod 0 4 0.0
total 0 33 0.0


line stmt bran cond sub pod time code
1             package Webqq::Client::Cache;
2             sub new{
3 0     0 0   return bless {}
4             }
5             sub store {
6 0     0 0   my $self= shift;
7 0           my ($data_key,$data,$ttl) = @_;
8 0           $self->{$data_key}{data} = $data;
9 0           $self->{$data_key}{ttl} = $ttl;
10 0           $self->{$data_key}{ctime} = time;
11            
12             }
13             sub delete {
14 0     0 0   my $self= shift;
15 0           my $data_key = shift;
16 0           delete $self->{$data_key};
17             }
18             sub retrieve{
19 0     0 0   my $self = shift;
20 0           my $data_key = shift;
21 0 0         if(exists $self->{$data_key} ){
  0            
22 0 0         if(defined $self->{$data_key}{ttl}){
23 0 0         if($self->{$data_key}{ttl} + $self->{$data_key}{ctime} > time){
  0            
24 0           return $self->{$data_key}{data};
25             }
26 0           else{delete $self->{$data_key};return undef}
27             }
28             else{
29 0           return $self->{$data_key}{data};
30             }
31             }
32             else{return undef}
33             }
34             1;