BIMI/CacheBackend/FastMmap.pm

filter: Statementstmt 100% 22 / 22 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 3 / 3 totaltotal 100% 35 / 35 CC 2 SCAR 2.0
CC
2
Cov
100%
_build_cache_fastmmap
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« BIMI/Role/Data.pm ↑ Summary BIMI/App.pm »
1 package Mail::BIMI::CacheBackend::FastMmap;
2 # ABSTRACT: Cache handling
3 29 our $VERSION = '3.20260302'; # VERSION
4 29 ▶use 5.20.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 29 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 29 ▶use Mail::BIMI::Prelude;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 29 ▶use Cache::FastMmap;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 29 with 'Mail::BIMI::Role::CacheBackend';
10 29 has _cache_fastmmap => ( is => 'rw', lazy => 1, builder => '_build_cache_fastmmap' );
11  
12  
13 ▶sub _build_cache_fastmmap($self) {
Subroutine _build_cache_fastmmap: called CC=2 SCAR=6.9
14 9 my $cache_filename = $self->parent->bimi_object->options->cache_fastmmap_share_file;
15 9 ▶ my $init_file = -e $cache_filename ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
-e $cache_filename ? : 8 1 9
16 9 my $cache = Cache::FastMmap->new( share_file => $cache_filename, serializer => 'sereal', init_file => $init_file, unlink_on_exit => 0 );
17 9 return $cache;
18 }
19  
20  
21 ▶sub get_from_cache($self) {
Subroutine get_from_cache: called CC=1 SCAR=0.0
Pod documented
22 9 return $self->_cache_fastmmap->get($self->_cache_hash);
23 }
24  
25  
26 ▶sub put_to_cache($self,$data) {
Subroutine put_to_cache: called CC=1 SCAR=0.0
Pod documented
27 2 $self->_cache_fastmmap->set($self->_cache_hash,$data);
28 }
29  
30  
31 ▶sub delete_cache($self) {
Subroutine delete_cache: called CC=1 SCAR=0.0
Pod documented
32 2 $self->_cache_fastmmap->remove($self->_cache_hash);
33 }
34  
35 29 1;
36  
37 __END__
38  
39 =pod
40  
41 =encoding UTF-8
42  
43 =head1 NAME
44  
45 Mail::BIMI::CacheBackend::FastMmap - Cache handling
46  
47 =head1 VERSION
48  
49 version 3.20260302
50  
51 =head1 DESCRIPTION
52  
53 Cache worker role for Cache::FastMmap backend
54  
55 =head1 ATTRIBUTES
56  
57 These values are derived from lookups and verifications made based upon the input values, it is however possible to override these with other values should you wish to, for example, validate a record before it is published in DNS, or validate an Indicator which is only available locally
58  
59 =head2 parent
60  
61 is=ro required
62  
63 Parent class for cacheing
64  
65 =head1 CONSUMES
66  
67 =over 4
68  
69 =item * L<Mail::BIMI::Role::CacheBackend>
70  
71 =back
72  
73 =head1 EXTENDS
74  
75 =over 4
76  
77 =item * L<Moose::Object>
78  
79 =back
80  
81 =head1 METHODS
82  
83 =head2 I<get_from_cache()>
84  
85 Retrieve this class data from cache
86  
87 =head2 I<put_to_cache($data)>
88  
89 Put this classes data into the cache
90  
91 =head2 I<delete_cache>
92  
93 Delete the cache entry for this class
94  
95 =head1 REQUIRES
96  
97 =over 4
98  
99 =item * L<Cache::FastMmap|Cache::FastMmap>
100  
101 =item * L<Mail::BIMI::Prelude|Mail::BIMI::Prelude>
102  
103 =item * L<Moose|Moose>
104  
105 =back
106  
107 =head1 AUTHOR
108  
109 Marc Bradshaw <marc@marcbradshaw.net>
110  
111 =head1 COPYRIGHT AND LICENSE
112  
113 This software is copyright (c) 2020 by Marc Bradshaw.
114  
115 This is free software; you can redistribute it and/or modify it under
116 the same terms as the Perl 5 programming language system itself.
117  
118 =cut
« BIMI/Role/Data.pm ↑ Summary BIMI/App.pm »