line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Catalyst::Plugin::Cache::Store::FastMmap; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
48315
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
27
|
|
6
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
41
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = "0.02"; |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
718
|
use Path::Class (); |
|
1
|
|
|
|
|
34751
|
|
|
1
|
|
|
|
|
21
|
|
11
|
1
|
|
|
1
|
|
8
|
use File::Spec (); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
46
|
|
12
|
1
|
|
|
1
|
|
497
|
use Catalyst::Utils (); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use Catalyst::Plugin::Cache::Backend::FastMmap; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub setup_fastmmap_cache_backend { |
16
|
|
|
|
|
|
|
my ( $app, $name, $config ) = @_; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
$config->{share_file} ||= File::Spec->catfile( Catalyst::Utils::class2tempdir($app), "cache_$name" ); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# make sure it exists |
21
|
|
|
|
|
|
|
Path::Class::file( $config->{share_file} )->parent->mkpath; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
$app->register_cache_backend( |
24
|
|
|
|
|
|
|
$name => Catalyst::Plugin::Cache::Backend::FastMmap->new( %$config ) |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
__PACKAGE__; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
__END__ |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=pod |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 NAME |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Catalyst::Plugin::Cache::Store::FastMmap - B<DEPRECATED> - FastMmap cache store |
37
|
|
|
|
|
|
|
for L<Catalyst::Plugin::Cache>. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 SYNOPSIS |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# instead of using this plugin, you can now do this: |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
use Catalyst qw/ |
44
|
|
|
|
|
|
|
Cache |
45
|
|
|
|
|
|
|
/; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
__PACKAGE__->config( cache => { |
48
|
|
|
|
|
|
|
backend => { |
49
|
|
|
|
|
|
|
class => "Cache:FastMmap", |
50
|
|
|
|
|
|
|
share_file => "/path/to/file", |
51
|
|
|
|
|
|
|
cache_size => "16m", |
52
|
|
|
|
|
|
|
}, |
53
|
|
|
|
|
|
|
}); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 STATUS |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
This plugin is deprecated because L<Cache::FastMmap> no longer needs to be |
58
|
|
|
|
|
|
|
wrapped to store plain values. It is still available on the CPAN for backwards |
59
|
|
|
|
|
|
|
compatibility and will still work with newer versions of Cache::FastMmap with a |
60
|
|
|
|
|
|
|
slight performance degredation. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 DESCRIPTION |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
This store plugin is a bit of a wrapper for L<Cache::FastMmap>. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
While you could normally just configure with |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
backend => { |
69
|
|
|
|
|
|
|
class => "Cache::FastMmap", |
70
|
|
|
|
|
|
|
share_file => ..., |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
L<Cache::FastMmap> can't store plain values by default. This module ships with |
74
|
|
|
|
|
|
|
a subclass that will wrap all values in a scalar reference before storing. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
This store plugin will try to provide a default C<share_file> as well, that |
77
|
|
|
|
|
|
|
won't clash with other apps. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 CONFIGURATION |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
See L<Catalyst::Plugin::Cache/CONFIGURATION> for a general overview of cache |
82
|
|
|
|
|
|
|
plugin configuration. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
This plugin just takes a hash reference in the backend field and passes it on |
85
|
|
|
|
|
|
|
to L<Cache::FastMmap>. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 SEE ALSO |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
L<Catalyst::Plugin::Cache>, L<Cache::FastMmap>. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 AUTHOR |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Yuval Kogman, C<nothingmuch@woobling.org> |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Copyright (c) Yuval Kogman, 2006. All rights reserved. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
This library is free software, you can redistribute it and/or modify it under |
100
|
|
|
|
|
|
|
the same terms as Perl itself, as well as under the terms of the MIT license. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
103
|
|
|
|
|
|
|
|