| 1 | package Mail::BIMI::CacheBackend::FastMmap; | ||||||||||
| 2 | # ABSTRACT: Cache handling | ||||||||||
| 3 | 29 | our $VERSION = '3.20261116'; # 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 | 9 | ▶ | 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
| |||||||||||
| 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 | 9 | ▶ | 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 | 2 | ▶ | 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 | 2 | ▶ | 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__ | ||||||||||