line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CHI::t::Driver::FastMmap; |
2
|
|
|
|
|
|
|
$CHI::t::Driver::FastMmap::VERSION = '0.61'; |
3
|
1
|
|
|
1
|
|
529
|
use strict; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
34
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
5
|
1
|
|
|
1
|
|
390
|
use CHI::Test; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
8
|
|
6
|
1
|
|
|
1
|
|
7
|
use Encode; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
81
|
|
7
|
1
|
|
|
1
|
|
1129
|
use File::Temp qw(tempdir); |
|
1
|
|
|
|
|
18769
|
|
|
1
|
|
|
|
|
67
|
|
8
|
1
|
|
|
1
|
|
8
|
use base qw(CHI::t::Driver); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
758
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $root_dir; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub required_modules { |
13
|
1
|
|
|
1
|
0
|
7
|
return { 'Cache::FastMmap' => undef }; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new_cache_options { |
17
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
0
|
|
|
|
$root_dir ||= |
20
|
|
|
|
|
|
|
tempdir( "chi-driver-fastmmap-XXXX", TMPDIR => 1, CLEANUP => 1 ); |
21
|
0
|
|
|
|
|
|
return ( $self->SUPER::new_cache_options(), root_dir => $root_dir ); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub test_fm_cache : Tests { |
25
|
0
|
|
|
0
|
0
|
0
|
my ($self) = @_; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# Create brand new cache and check defaults |
28
|
0
|
|
|
|
|
0
|
my $cache = |
29
|
|
|
|
|
|
|
$self->new_cache( root_dir => |
30
|
|
|
|
|
|
|
tempdir( "chi-driver-fastmmap-XXXX", TMPDIR => 1, CLEANUP => 1 ) ); |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
0
|
my $fm_cache = $cache->fm_cache(); |
33
|
0
|
|
|
|
|
0
|
isa_ok( $fm_cache, 'Cache::FastMmap' ); |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
0
|
my %defaults = ( |
36
|
|
|
|
|
|
|
unlink_on_exit => 0, |
37
|
|
|
|
|
|
|
empty_on_exit => 0, |
38
|
|
|
|
|
|
|
raw_values => 1, |
39
|
|
|
|
|
|
|
); |
40
|
0
|
|
|
|
|
0
|
while ( my ( $key, $value ) = each(%defaults) ) { |
41
|
0
|
|
0
|
|
|
0
|
is( $fm_cache->{$key} || 0, $value, "$key = $value by default" ); |
42
|
|
|
|
|
|
|
} |
43
|
1
|
|
|
1
|
|
8
|
} |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub test_parameter_passthrough : Tests { |
46
|
0
|
|
|
0
|
0
|
0
|
my ($self) = @_; |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
0
|
my $cache = $self->new_cache( cache_size => '500k' ); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# The number gets munged by FastMmap so it's not equal to 500 * 1024 |
51
|
|
|
|
|
|
|
is( $cache->fm_cache()->{cache_size}, |
52
|
0
|
|
|
|
|
0
|
589824, |
53
|
|
|
|
|
|
|
'cache_size parameter is passed to Cache::FastMmap constructor' ); |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
0
|
$cache = $self->new_cache( page_size => 5000, num_pages => 11 ); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# Same here, it won't be equal to 5000 * 11 |
58
|
0
|
|
|
|
|
0
|
is( $cache->fm_cache()->{cache_size}, 45056, |
59
|
|
|
|
|
|
|
'page_size and num_pages parameters are passed to Cache::FastMmap constructor' |
60
|
|
|
|
|
|
|
); |
61
|
1
|
|
|
1
|
|
369
|
} |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
5
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub test_value_too_large : Tests { |
64
|
0
|
|
|
0
|
0
|
0
|
my ($self) = @_; |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
0
|
my $cache = $self->new_cache( |
67
|
|
|
|
|
|
|
page_size => '4k', |
68
|
|
|
|
|
|
|
num_pages => 11, |
69
|
|
|
|
|
|
|
on_set_error => 'die' |
70
|
|
|
|
|
|
|
); |
71
|
0
|
|
|
|
|
0
|
my %values; |
72
|
0
|
|
|
|
|
0
|
$values{small} = 'x' x 3 x 1024; |
73
|
0
|
|
|
|
|
0
|
$values{large} = 'x' x 10 x 1024; |
74
|
0
|
|
|
|
|
0
|
$cache->set( 'small', $values{small} ); |
75
|
0
|
|
|
|
|
0
|
is( $cache->get('small'), $values{small}, "got small" ); |
76
|
0
|
|
|
0
|
|
0
|
throws_ok { $cache->set( 'large', $values{large} ) } |
77
|
0
|
|
|
|
|
0
|
qr/error during cache set.*fastmmap set failed/; |
78
|
1
|
|
|
1
|
|
436
|
} |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
13
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |