Changeset 1026

Show
Ignore:
Timestamp:
06/30/06 10:59:52
Author:
miyagawa
Message:

Purge cache on the global destruction phase of every run. Fixes #306.
via http://d.hatena.ne.jp/s_nobu/20060619/1150709563

Files:

Legend:

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

    r1024 r1026  
    151151    my $dir  = $base eq 'config' ? ".plagger" : ".plagger-$base"; 
    152152 
    153     $self->{conf}->{cache} ||= { 
    154         base => File::Spec->catfile($ENV{HOME}, $dir), 
    155     }; 
     153    # cache is auto-vivified but that's okay 
     154    $self->{conf}->{cache}->{base} ||= File::Spec->catfile($ENV{HOME}, $dir); 
    156155 
    157156    $self->cache( Plagger::Cache->new($self->{conf}->{cache}) ); 
     
    409408} 
    410409 
    411  
    4124101; 
    413411__END__ 
  • trunk/plagger/lib/Plagger/Cache.pm

    r718 r1026  
    1515    $conf->{params} ||= { 
    1616        cache_root => File::Spec->catfile($conf->{base}, 'cache'), 
     17        default_expires_in => $conf->{expires} || 'never', 
    1718    }; 
    1819 
     
    2930        base  => $conf->{base}, 
    3031        cache => $conf->{class}->new($conf->{params}), 
     32        to_purge => $conf->{expires} ? 1 : 0, 
    3133    }, $class; 
    3234} 
     
    103105} 
    104106 
     107sub DESTROY { 
     108    my $self = shift; 
     109    $self->{cache}->purge() if $self->{to_purge}; 
     110} 
     111 
    1051121;