line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CHI::t::Driver::Subcache::l1_cache; |
2
|
|
|
|
|
|
|
$CHI::t::Driver::Subcache::l1_cache::VERSION = '0.59'; |
3
|
1
|
|
|
1
|
|
365
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
27
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
17
|
|
5
|
1
|
|
|
1
|
|
290
|
use CHI::Test; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use CHI::Test::Util qw(activate_test_logger); |
7
|
|
|
|
|
|
|
use File::Temp qw(tempdir); |
8
|
|
|
|
|
|
|
use base qw(CHI::t::Driver::Subcache); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $root_dir; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub testing_driver_class { |
13
|
|
|
|
|
|
|
return 'CHI::Driver::File'; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new_cache_options { |
17
|
|
|
|
|
|
|
my $self = shift; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
$root_dir ||= |
20
|
|
|
|
|
|
|
tempdir( "chi-driver-subcache-l1-XXXX", TMPDIR => 1, CLEANUP => 1 ); |
21
|
|
|
|
|
|
|
return ( |
22
|
|
|
|
|
|
|
$self->SUPER::new_cache_options(), |
23
|
|
|
|
|
|
|
root_dir => $root_dir, |
24
|
|
|
|
|
|
|
l1_cache => { driver => 'Memory', global => 1 }, |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub test_stats : Tests { |
29
|
|
|
|
|
|
|
my $self = shift; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
my $stats = $self->testing_chi_root_class->stats; |
32
|
|
|
|
|
|
|
$stats->enable(); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my ( $key, $value ) = $self->kvpair(); |
35
|
|
|
|
|
|
|
my $start_time = time(); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my $cache; |
38
|
|
|
|
|
|
|
$cache = $self->new_cache( namespace => 'Foo' ); |
39
|
|
|
|
|
|
|
$cache->get($key); |
40
|
|
|
|
|
|
|
$cache->set( $key, $value, 80 ); |
41
|
|
|
|
|
|
|
$cache->get($key); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my $log = activate_test_logger(); |
44
|
|
|
|
|
|
|
$log->empty_ok(); |
45
|
|
|
|
|
|
|
$stats->flush(); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
$log->contains_ok( |
48
|
|
|
|
|
|
|
qr/CHI stats: {"absent_misses":1,"end_time":\d+,"get_time_ms":\d+,"label":"File","namespace":"Foo","root_class":"CHI","set_key_size":6,"set_time_ms":\d+,"set_value_size":20,"sets":1,"start_time":\d+}/ |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
$log->contains_ok( |
51
|
|
|
|
|
|
|
qr/CHI stats: {"absent_misses":1,"end_time":\d+,"get_time_ms":\d+,"hits":1,"label":"File:l1_cache","namespace":"Foo","root_class":"CHI","set_key_size":6,"set_time_ms":\d+,"set_value_size":20,"sets":1,"start_time":\d+}/ |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# not working yet |
57
|
|
|
|
|
|
|
sub test_append { } |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# won't work in presence of l1 cache |
60
|
|
|
|
|
|
|
sub test_max_key_length { } |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |