line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CHI::t::Driver::FastMmap; |
2
|
|
|
|
|
|
|
$CHI::t::Driver::FastMmap::VERSION = '0.60'; |
3
|
1
|
|
|
1
|
|
357
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
20
|
|
5
|
1
|
|
|
1
|
|
325
|
use CHI::Test; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
6
|
1
|
|
|
1
|
|
6
|
use Encode; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
91
|
|
7
|
1
|
|
|
1
|
|
924
|
use File::Temp qw(tempdir); |
|
1
|
|
|
|
|
17620
|
|
|
1
|
|
|
|
|
66
|
|
8
|
1
|
|
|
1
|
|
6
|
use base qw(CHI::t::Driver); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
640
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $root_dir; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub required_modules { |
13
|
1
|
|
|
1
|
0
|
6
|
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
|
|
6
|
} |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
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
|
0
|
|
|
|
|
0
|
is( $cache->fm_cache()->{cache_size}, |
52
|
|
|
|
|
|
|
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
|
|
339
|
} |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
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
|
|
369
|
} |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |