| 1 | package Mail::BIMI::Role::CacheBackend; | ||
| 2 | # ABSTRACT: Cache handling backend | ||
| 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::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 | ▶ | 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__ | ||
| 29 | |||
| 30 | =pod | ||
| 31 | |||
| 32 | =encoding UTF-8 | ||
| 33 | |||
| 34 | =head1 NAME | ||
| 35 | |||
| 36 | Mail::BIMI::Role::CacheBackend - Cache handling backend | ||
| 37 | |||
| 38 | =head1 VERSION | ||
| 39 | |||
| 40 | version 3.20260302 | ||
| 41 | |||
| 42 | =head1 DESCRIPTION | ||
| 43 | |||
| 44 | Role for implementing a cache backend | ||
| 45 | |||
| 46 | =head1 REQUIRES | ||
| 47 | |||
| 48 | =over 4 | ||
| 49 | |||
| 50 | =item * L<Digest::SHA|Digest::SHA> | ||
| 51 | |||
| 52 | =item * L<Mail::BIMI::Prelude|Mail::BIMI::Prelude> | ||
| 53 | |||
| 54 | =item * L<Moose::Role|Moose::Role> | ||
| 55 | |||
| 56 | =back | ||
| 57 | |||
| 58 | =head1 AUTHOR | ||
| 59 | |||
| 60 | Marc Bradshaw <marc@marcbradshaw.net> | ||
| 61 | |||
| 62 | =head1 COPYRIGHT AND LICENSE | ||
| 63 | |||
| 64 | This software is copyright (c) 2020 by Marc Bradshaw. | ||
| 65 | |||
| 66 | This is free software; you can redistribute it and/or modify it under | ||
| 67 | the same terms as the Perl 5 programming language system itself. | ||
| 68 | |||
| 69 | =cut | ||