Changeset 239

Show
Ignore:
Timestamp:
03/02/06 16:04:38
Author:
miyagawa
Message:

Fallbacks to on process memory cache when Cache module is not installed. Fixes #85

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plagger/lib/Plagger.pm

    r225 r239  
    5050    } 
    5151 
     52    local *Plagger::context = sub { $self }; 
     53 
    5254    $self->load_cache($opt{config}); 
    53  
    54     local *Plagger::context = sub { $self }; 
    5555    $self->load_plugins(@{ $config->{plugins} || [] }); 
    5656    $self->run(); 
  • trunk/plagger/lib/Plagger/Cache.pm

    r238 r239  
    1414    $conf->{params} ||= { 
    1515        cache_root         => File::Spec->catfile($conf->{base}, 'cache'), 
    16         default_expires_in => '30 minutes', 
    1716    }; 
    1817 
    19     $conf->{class}->require or die $@; 
     18    $conf->{class}->require; 
     19 
     20    # If class is not loadable, falls back to on memory cache 
     21    if ($@) { 
     22        Plagger->context->log(error => "Can't load $conf->{class}. Fallbacks to Plagger::Cache::Null"); 
     23        require Plagger::Cache::Null; 
     24        $conf->{class} = 'Plagger::Cache::Null'; 
     25    } 
    2026 
    2127    my $self = bless {