| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Cache::FastMmap::Tie; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 5 |  |  | 5 |  | 29 | use strict; | 
|  | 5 |  |  |  |  | 10 |  | 
|  | 5 |  |  |  |  | 185 |  | 
| 4 | 5 |  |  | 5 |  | 66 | use v5.8.1; | 
|  | 5 |  |  |  |  | 14 |  | 
|  | 5 |  |  |  |  | 341 |  | 
| 5 |  |  |  |  |  |  | our $VERSION = '0.03'; | 
| 6 |  |  |  |  |  |  |  | 
| 7 | 5 |  |  | 5 |  | 26 | use base 'Cache::FastMmap'; | 
|  | 5 |  |  |  |  | 7 |  | 
|  | 5 |  |  |  |  | 6711 |  | 
| 8 | 5 |  |  | 5 |  | 36278 | use Class::Inspector; | 
|  | 5 |  |  |  |  | 16854 |  | 
|  | 5 |  |  |  |  | 205 |  | 
| 9 | 5 |  |  | 5 |  | 3686 | use Best [ [ qw/YAML::XS YAML::Syck YAML/ ], qw/LoadFile/ ]; | 
|  | 5 |  |  |  |  | 23593 |  | 
|  | 5 |  |  |  |  | 42 |  | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | sub TIEHASH{ | 
| 12 | 4 |  |  | 4 |  | 199 | my $class = shift; | 
| 13 | 4 |  |  |  |  | 11 | my ($params_hash) = @_; | 
| 14 | 4 |  |  |  |  | 7 | my $self; | 
| 15 | 4 | 100 |  |  |  | 21 | if (ref $params_hash eq 'HASH') { | 
| 16 | 1 |  |  |  |  | 2 | $params_hash = shift @_; | 
| 17 | 1 | 50 |  |  |  | 6 | if (my $yaml_file = delete $params_hash->{yaml_file}) { | 
| 18 | 1 | 50 |  |  |  | 9 | $params_hash = LoadFile("$yaml_file") or | 
| 19 |  |  |  |  |  |  | die "Can't open `$yaml_file':$@ ",__LINE__; | 
| 20 |  |  |  |  |  |  | } | 
| 21 | 1 | 50 |  |  |  | 20285 | $self = $class->new(%{$params_hash}) unless @_; | 
|  | 1 |  |  |  |  | 20 |  | 
| 22 |  |  |  |  |  |  | } | 
| 23 | 4 |  | 66 |  |  | 6534 | $self ||= $class->new(@_); | 
| 24 | 4 |  |  |  |  | 163226 | $self->{_tie_var} = {}; | 
| 25 | 4 |  |  |  |  | 83 | return $self; | 
| 26 |  |  |  |  |  |  | } | 
| 27 |  |  |  |  |  |  |  | 
| 28 | 8 |  |  | 8 |  | 1183 | sub STORE { shift->set(@_) } # ( Key => Value ) | 
| 29 |  |  |  |  |  |  |  | 
| 30 | 14 |  |  | 14 |  | 1959 | sub FETCH { shift->get(@_) } # ( Key ) | 
| 31 |  |  |  |  |  |  |  | 
| 32 | 0 |  |  | 0 |  | 0 | sub DELETE{ shift->remove(@_) } # ( Key ) | 
| 33 |  |  |  |  |  |  |  | 
| 34 | 0 |  |  | 0 |  | 0 | sub CLEAR { shift->clear } | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | sub EXISTS { # ( Key ) | 
| 37 | 9 |  |  | 9 |  | 1002226 | my $self = shift; | 
| 38 | 9 |  |  |  |  | 81 | $self->purge; | 
| 39 | 9 |  |  |  |  | 63563 | for ($self->get_keys(0)){ | 
| 40 | 5 | 50 |  |  |  | 5799 | $_ eq  $_[0] and return 1; | 
| 41 |  |  |  |  |  |  | } | 
| 42 | 4 |  |  |  |  | 3494 | return ; | 
| 43 |  |  |  |  |  |  | } | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  | sub FIRSTKEY { | 
| 46 | 12 |  |  | 12 |  | 3178 | my $self = shift; | 
| 47 | 12 |  |  |  |  | 62 | $self->purge; | 
| 48 | 12 |  |  |  |  | 53787 | @{$self->{_tie_var}->{get_keys_0}} = $self->get_keys(0); | 
|  | 12 |  |  |  |  | 8717 |  | 
| 49 | 12 |  |  |  |  | 25 | shift @{$self->{_tie_var}->{get_keys_0}}; | 
|  | 12 |  |  |  |  | 96 |  | 
| 50 |  |  |  |  |  |  | } | 
| 51 |  |  |  |  |  |  |  | 
| 52 |  |  |  |  |  |  | sub NEXTKEY { # ( prevKey ) | 
| 53 | 16 |  |  | 16 |  | 27 | my $self = shift; | 
| 54 | 16 |  |  |  |  | 24 | shift @{$self->{_tie_var}->{get_keys_0}}; | 
|  | 16 |  |  |  |  | 96 |  | 
| 55 |  |  |  |  |  |  | } | 
| 56 |  |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  | #sub DESTROY {} | 
| 58 |  |  |  |  |  |  |  | 
| 59 |  |  |  |  |  |  | 1; | 
| 60 |  |  |  |  |  |  | __END__ |