| 1 | =head1 NAME | ||||||||||||
| 2 | |||||||||||||
| 3 | OpenFrame::WebApp::Session::CacheBase - abstract base for sessions using | ||||||||||||
| 4 | Cache::Cache modules | ||||||||||||
| 5 | |||||||||||||
| 6 | =head1 SYNOPSIS | ||||||||||||
| 7 | |||||||||||||
| 8 | # abstract class - cannot be instantiated | ||||||||||||
| 9 | use base qw( OpenFrame::WebApp::Session::CacheBase ); | ||||||||||||
| 10 | |||||||||||||
| 11 | =cut | ||||||||||||
| 12 | |||||||||||||
| 13 | package OpenFrame::WebApp::Session::CacheBase; | ||||||||||||
| 14 | |||||||||||||
| 15 | 8 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 16 | 8 | ▶ | use warnings::register; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 17 | |||||||||||||
| 18 | 8 | ▶ | use Error; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 19 | 8 | ▶ | use OpenFrame::WebApp::Error::Abstract; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 20 | |||||||||||||
| 21 | 8 | our $VERSION = (split(/ /, '$Revision: 1.1 $'))[1]; | |||||||||||
| 22 | |||||||||||||
| 23 | 8 | ▶ | use base qw( OpenFrame::WebApp::Session ); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 24 | |||||||||||||
| 25 | 0 | ▶ | sub cache_class { | ||||||||||
|
Subroutine
cache_class: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 26 | 0 | my $self = shift; | |||||||||||
| 27 | 0 | throw OpenFrame::WebApp::Error::Abstract( class => ref($self) ); | |||||||||||
| 28 | } | ||||||||||||
| 29 | |||||||||||||
| 30 | 4 | ▶ | sub store { | ||||||||||
|
Subroutine
store: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||
| 31 | 4 | my $self = shift; | |||||||||||
| 32 | 4 | my $expiry = $self->get_expiry_seconds; | |||||||||||
| 33 | 4 | my @args = ($self->id, $self); | |||||||||||
| 34 | 4 | ▶ | push (@args, "$expiry s") if (defined $expiry); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 35 | 4 | $self->cache_class->new()->set( @args ); | |||||||||||
| 36 | 4 | return $self->id; | |||||||||||
| 37 | } | ||||||||||||
| 38 | |||||||||||||
| 39 | 4 | ▶ | sub fetch { | ||||||||||
|
Subroutine
fetch: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||
| 40 | 4 | my $class = shift; | |||||||||||
| 41 | 4 | ▶ | my $id = shift || return; | ||||||||||
|
Condition50%1/2
shift() || (return)
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||
| 42 | 4 | return $class->cache_class->new({auto_purge_on_get => 1})->get( $id ); | |||||||||||
| 43 | } | ||||||||||||
| 44 | |||||||||||||
| 45 | 4 | ▶ | sub remove { | ||||||||||
|
Subroutine
remove: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||
| 46 | 4 | my $self = shift; | |||||||||||
| 47 | 4 | ▶ | my $id = ref($self) ? $self->id : shift; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 48 | 4 | $self->cache_class->new()->remove( $id ); | |||||||||||
| 49 | 4 | return $self; | |||||||||||
| 50 | } | ||||||||||||
| 51 | |||||||||||||
| 52 | |||||||||||||
| 53 | 8 | 1; | |||||||||||
| 54 | |||||||||||||
| 55 | =head1 DESCRIPTION | ||||||||||||
| 56 | |||||||||||||
| 57 | An C<OpenFrame::WebApp::Session> for using C<Cache::Cache> modules. | ||||||||||||
| 58 | |||||||||||||
| 59 | =head1 AUTHOR | ||||||||||||
| 60 | |||||||||||||
| 61 | Steve Purkis <spurkis@epn.nu> | ||||||||||||
| 62 | |||||||||||||
| 63 | Based on C<OpenFrame::AppKit::Session>, by James A. Duncan. | ||||||||||||
| 64 | |||||||||||||
| 65 | =head1 COPYRIGHT | ||||||||||||
| 66 | |||||||||||||
| 67 | Copyright (c) 2003 Steve Purkis. All rights reserved. | ||||||||||||
| 68 | Released under the same license as Perl itself. | ||||||||||||
| 69 | |||||||||||||
| 70 | =head1 SEE ALSO | ||||||||||||
| 71 | |||||||||||||
| 72 | L<Cache::Cache>, | ||||||||||||
| 73 | L<OpenFrame::WebApp::Sesssion>, | ||||||||||||
| 74 | L<OpenFrame::WebApp::Session::MemCache>, | ||||||||||||
| 75 | L<OpenFrame::WebApp::Session::FileCache> | ||||||||||||
| 76 | |||||||||||||
| 77 | =cut | ||||||||||||