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.60'; |
3
|
1
|
|
|
1
|
|
546
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
49
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
29
|
|
5
|
1
|
|
|
1
|
|
379
|
use CHI::Test; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
9
|
|
6
|
1
|
|
|
1
|
|
8
|
use CHI::Test::Util qw(activate_test_logger); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
82
|
|
7
|
1
|
|
|
1
|
|
858
|
use File::Temp qw(tempdir); |
|
1
|
|
|
|
|
19501
|
|
|
1
|
|
|
|
|
107
|
|
8
|
1
|
|
|
1
|
|
11
|
use base qw(CHI::t::Driver::Subcache); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
417
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $root_dir; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub testing_driver_class { |
13
|
80
|
|
|
80
|
0
|
1229
|
return 'CHI::Driver::File'; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new_cache_options { |
17
|
80
|
|
|
80
|
0
|
162
|
my $self = shift; |
18
|
|
|
|
|
|
|
|
19
|
80
|
|
66
|
|
|
305
|
$root_dir ||= |
20
|
|
|
|
|
|
|
tempdir( "chi-driver-subcache-l1-XXXX", TMPDIR => 1, CLEANUP => 1 ); |
21
|
|
|
|
|
|
|
return ( |
22
|
80
|
|
|
|
|
1502
|
$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
|
1
|
|
|
1
|
0
|
347
|
my $self = shift; |
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
10
|
my $stats = $self->testing_chi_root_class->stats; |
32
|
1
|
|
|
|
|
7
|
$stats->enable(); |
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
|
|
7
|
my ( $key, $value ) = $self->kvpair(); |
35
|
1
|
|
|
|
|
5
|
my $start_time = time(); |
36
|
|
|
|
|
|
|
|
37
|
1
|
|
|
|
|
2
|
my $cache; |
38
|
1
|
|
|
|
|
10
|
$cache = $self->new_cache( namespace => 'Foo' ); |
39
|
1
|
|
|
|
|
33
|
$cache->get($key); |
40
|
1
|
|
|
|
|
33
|
$cache->set( $key, $value, 80 ); |
41
|
1
|
|
|
|
|
33
|
$cache->get($key); |
42
|
|
|
|
|
|
|
|
43
|
1
|
|
|
|
|
6
|
my $log = activate_test_logger(); |
44
|
1
|
|
|
|
|
9
|
$log->empty_ok(); |
45
|
1
|
|
|
|
|
787
|
$stats->flush(); |
46
|
|
|
|
|
|
|
|
47
|
1
|
|
|
|
|
9
|
$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
|
1
|
|
|
|
|
655
|
$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
|
1
|
|
|
1
|
|
6
|
} |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# not working yet |
57
|
1
|
|
|
1
|
0
|
168
|
sub test_append { } |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# won't work in presence of l1 cache |
60
|
1
|
|
|
1
|
0
|
757
|
sub test_max_key_length { } |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |