| 1 | package Mojo::Webqq::Cache; | ||||||||||
| 2 | 0 | ▶ | sub new{ | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 3 | 0 | return bless {} | |||||||||
| 4 | } | ||||||||||
| 5 | 0 | ▶ | sub store { | ||||||||
|
Subroutine
store: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 6 | 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 | 0 | ▶ | sub delete { | ||||||||
|
Subroutine
delete: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 14 | 0 | my $self= shift; | |||||||||
| 15 | 0 | my $data_key = shift; | |||||||||
| 16 | 0 | delete $self->{$data_key}; | |||||||||
| 17 | } | ||||||||||
| 18 | 0 | ▶ | sub retrieve{ | ||||||||
|
Subroutine
retrieve: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||
| 19 | 0 | my $self = shift; | |||||||||
| 20 | 0 | my $data_key = shift; | |||||||||
| 21 | 0 | ▶ | if(exists $self->{$data_key} ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 22 | 0 | ▶ | if(defined $self->{$data_key}{ttl}){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | 0 | ▶ | if($self->{$data_key}{ttl} + $self->{$data_key}{ctime} > time){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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 | 0 | else{return undef} | |||||||||
| 33 | } | ||||||||||
| 34 | 1 | 1; | |||||||||