| 1 | package OpenInteract2::Setup::InitializeCache; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | # $Id: InitializeCache.pm,v 1.2 2005/03/18 04:09:51 lachoy Exp $ | ||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 87 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 87 | ▶ | use base qw( OpenInteract2::Setup ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 87 | ▶ | use Log::Log4perl qw( get_logger ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 87 | ▶ | use OpenInteract2::Constants qw( :log ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | 87 | ▶ | use OpenInteract2::Exception qw( oi_error ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 87 | $OpenInteract2::Setup::InitializeCache::VERSION = sprintf("%d.%02d", q$Revision: 1.2 $ =~ /(\d+)\.(\d+)/); | |||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 87 | my ( $log ); | |||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 87 | ▶ | sub get_name { | ||||||||||||||||||
|
Subroutine
get_name: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 16 | 87 | return 'initialize cache'; | |||||||||||||||||||
| 17 | } | ||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | 0 | ▶ | sub execute { | ||||||||||||||||||
|
Subroutine
execute: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||
| 20 | 0 | my ( $self, $ctx ) = @_; | |||||||||||||||||||
| 21 | 0 | ▶ | $log ||= get_logger( LOG_INIT ); | ||||||||||||||||||
|
Condition0%0/3
$log ||= get_logger("OI2.INITIALIZE")
MC/DC0%0/2
$log ||= get_logger("OI2.INITIALIZE")
$log
get_logger("OI2.INITIALIZE")
Truth table0%0/3
A ||= B
A= $logB= get_logger("OI2.INITIALIZE")
| |||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 0 | ▶ | my $cache_config = $ctx->lookup_cache_config || {}; | ||||||||||||||||||
|
Condition0%0/2
$ctx->lookup_cache_config || {}
MC/DC0%0/1
$ctx->lookup_cache_config || {}
$ctx->lookup_cache_config
Truth table0%0/2
A
A= $ctx->lookup_cache_config
| |||||||||||||||||||||
| 24 | 0 | ▶ | unless ( 'yes' eq lc $cache_config->{use} ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 25 | 0 | $log->info( "Cache not configured for usage" ); | |||||||||||||||||||
| 26 | 0 | return; | |||||||||||||||||||
| 27 | } | ||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | 0 | my $cache_class = $cache_config->{class}; | |||||||||||||||||||
| 30 | 0 | $log->info( "Creating cache with class '$cache_class'" ); | |||||||||||||||||||
| 31 | 0 | OpenInteract2::Setup->new( | |||||||||||||||||||
| 32 | 'require classes', | ||||||||||||||||||||
| 33 | classes => $cache_class, | ||||||||||||||||||||
| 34 | classes_type => 'Cache class', | ||||||||||||||||||||
| 35 | )->run(); | ||||||||||||||||||||
| 36 | 0 | my $cache = $cache_class->new( $cache_config ); | |||||||||||||||||||
| 37 | 0 | $log->info( "Cache setup with '$cache_class' ok" ); | |||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | 0 | ▶ | if ( 'yes' eq lc $cache_config->{cleanup} ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 40 | 0 | $log->info( "Cache configured for cleanup at startup, purging..." ); | |||||||||||||||||||
| 41 | 0 | $cache->purge; | |||||||||||||||||||
| 42 | } | ||||||||||||||||||||
| 43 | 0 | $self->param( cache => $cache ); | |||||||||||||||||||
| 44 | 0 | $ctx->cache( $cache ); | |||||||||||||||||||
| 45 | } | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | 87 | OpenInteract2::Setup->register_factory_type( get_name() => __PACKAGE__ ); | |||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | 87 | 1; | |||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | __END__ | ||||||||||||||||||||