| 1 | package Mail::BIMI::Role::CacheBackend; | ||
| 2 | # ABSTRACT: Cache handling backend | ||
| 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::Role; |
|
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 Digest::SHA; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 29 | has parent => ( is => 'ro', required => 1, weak_ref => 1, | |
| 10 | documentation => 'Parent class for cacheing' ); | ||
| 11 | 29 | has _cache_hash => ( is => 'ro', lazy => 1, builder => '_build_cache_hash' ); | |
| 12 | 29 | requires 'get_from_cache'; | |
| 13 | 29 | requires 'put_to_cache'; | |
| 14 | 29 | requires 'delete_cache'; | |
| 15 | |||
| 16 | |||
| 17 | 30 | ▶ | sub _build_cache_hash($self) { |
|
Subroutine
_build_cache_hash: called CC=1 SCAR=0.0
| |||
| 18 | 30 | my $context = Digest::SHA->new; | |
| 19 | ## TODO make sure there are no wide characters present in cache key | ||
| 20 | 30 | $context->add($self->parent->_cache_key); | |
| 21 | 29 | my $hash = $context->hexdigest; | |
| 22 | 29 | $hash =~ s/ //g; | |
| 23 | 29 | return $hash; | |
| 24 | } | ||
| 25 | |||
| 26 | 29 | 1; | |
| 27 | |||
| 28 | __END__ | ||