| 1 | package HTTP::Session::Store::File; | ||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use base qw/Class::Accessor::Fast/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use Storable; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 1 | __PACKAGE__->mk_ro_accessors(qw/dir/); | |||||||||
| 8 | |||||||||||
| 9 | 2 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=4 SCAR=14.9
Pod
documented
| |||||||||||
| 10 | 2 | my $class = shift; | |||||||||
| 11 | 0 | ▶ | my %args = ref($_[0]) ? %{$_[0]} : @_; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 12 | # check requried parameters | ||||||||||
| 13 | 2 | for (qw/dir/) { | |||||||||
| 14 | 2 | ▶ | Carp::croak "missing parameter $_" unless $args{$_}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 15 | } | ||||||||||
| 16 | # set default values | ||||||||||
| 17 | 2 | bless {%args}, $class; | |||||||||
| 18 | } | ||||||||||
| 19 | |||||||||||
| 20 | 2 | ▶ | sub select { | ||||||||
|
Subroutine
select: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 21 | 2 | my ($self, $key) = @_; | |||||||||
| 22 | 2 | ▶ | if (open my $fh, '<', $self->_to_path($key)) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | 1 | my $value = Storable::fd_retrieve($fh); | |||||||||
| 24 | 1 | close $fh; | |||||||||
| 25 | 1 | return $value; | |||||||||
| 26 | } | ||||||||||
| 27 | 1 | undef; | |||||||||
| 28 | } | ||||||||||
| 29 | |||||||||||
| 30 | 1 | ▶ | sub insert { | ||||||||
|
Subroutine
insert: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 31 | 1 | my ($self, $key, $value) = @_; | |||||||||
| 32 | 1 | Storable::nstore $value, $self->_to_path($key); | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 0 | ▶ | sub update { | ||||||||
|
Subroutine
update: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 36 | 0 | shift->insert(@_); | |||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | 0 | ▶ | sub delete { | ||||||||
|
Subroutine
delete: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 40 | 0 | my ($self, $key) = @_; | |||||||||
| 41 | 0 | unlink $self->_to_path($key); | |||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | 3 | ▶ | sub _to_path { | ||||||||
|
Subroutine
_to_path: called CC=1 SCAR=0.2
| |||||||||||
| 45 | 3 | my ($self, $key) = @_; | |||||||||
| 46 | 0 | $key =~ s/([^A-Za-pr-z0-9_])/sprintf("q%02x", ord $1)/eg; | |||||||||
| 47 | 3 | $self->dir . '/' . $key . '.dat'; | |||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | 0 | ▶ | sub cleanup { Carp::croak "This storage doesn't support cleanup" } | ||||||||
|
Subroutine
cleanup: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 51 | |||||||||||
| 52 | 1 | 1; | |||||||||
| 53 | __END__ | ||||||||||