Jifty/CAS/Store/Memory.pm untested

filter: Statementstmt 0.0% 0 / 28 Branchbran n/a Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 42 CC 1 SCAR 6.9
CC
1
Cov
0%
_store
2.0
key
2.0
retrieve
2.0
CRAP 2.0
1 use strict;
2 use warnings;
3  
4 package Jifty::CAS::Store::Memory;
5 use Any::Moose;
6 extends 'Jifty::CAS::Store';
7  
8 =head1 NAME
9  
10 Jifty::CAS::Store::Memory - An single-process in-memory CAS store
11  
12 =head1 DESCRIPTION
13  
14 This is the default backend store for L<Jifty::CAS>. For more
15 information, see L<Jifty::CAS/DESCRIPTION>.
16  
17 =cut
18  
19 use Jifty::CAS::Blob;
20  
21 my %CONTAINER;
22  
23 =head2 _store DOMAIN NAME BLOB
24  
25 Stores the BLOB (a L<Jifty::CAS::Blob>) in the backend. Returns the
26 key. Don't use this directly, use C<publish> instead.
27  
28 =cut
29  
30 sub _store {
31 my ($self, $domain, $name, $blob) = @_;
32 my $db = $CONTAINER{$domain} ||= {};
33 my $key = $blob->key;
34 $db->{DB}{$key} = $blob;
35 $db->{KEYS}{$name} = $key;
36 return $key;
37 }
38  
39 =head2 key DOMAIN NAME
40  
41 Returns the most recent key for the given pair of C<DOMAIN> and
42 C<NAME>, or undef if none such exists.
43  
44 =cut
45  
46 sub key {
47 my ($self, $domain, $name) = @_;
48 return $CONTAINER{$domain}{KEYS}{$name};
49 }
50  
51 =head2 retrieve DOMAIN KEY
52  
53 Returns a L<Jifty::CAS::Blob> for the given pair of C<DOMAIN> and
54 C<KEY>, or undef if none such exists.
55  
56 =cut
57  
58 sub retrieve {
59 my ($self, $domain, $key) = @_;
60 return $CONTAINER{$domain}{DB}{$key};
61 }
62  
63 no Any::Moose;
64 __PACKAGE__->meta->make_immutable(inline_constructor => 0);
65 1;