[BACK]Return to Cached.pm CVS log [TXT][DIR] Up to [local] / openbsd / OpenBSDTorrents / lib / BT / MetaInfo

Diff for /openbsd/OpenBSDTorrents/lib/BT/MetaInfo/Cached.pm between version 1.5 and 1.6

version 1.5, 2005/05/05 21:08:04 version 1.6, 2005/05/05 21:10:50
Line 6 
Line 6 
 require 5.6.0;  require 5.6.0;
 use vars qw( $VERSION @ISA );  use vars qw( $VERSION @ISA );
   
 use YAML;  
   
 #use Digest::SHA1 qw(sha1);  
 #use YAML qw/ DumpFile LoadFile /;  
   
 use Cache::FileCache;  use Cache::FileCache;
 use File::Basename;  use File::Basename;
   
 use BT::MetaInfo;  use BT::MetaInfo;
 use base 'BT::MetaInfo';  use base 'BT::MetaInfo';
   
 #use OpenBSDTorrents;  
   
 $VERSION = do { my @r = (q$Id$ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };  $VERSION = do { my @r = (q$Id$ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
   
 sub new  sub new
Line 38 
Line 31 
         return(bless($obj, $class));          return(bless($obj, $class));
 }  }
   
 sub save {  sub _load {
         my ($self, $file) = @_;          my $file = shift;
           my $cache = shift;
   
         my $basename = basename($file);          my $basename = basename($file);
   
           my $info = $cache->get( $basename );
   
         $self->SUPER::save($file, @_);          unless (defined $info) {
                   $info = BT::MetaInfo::_load($file);
         my %info_hash = %$self; # unbless                  $cache->set( $basename, $info );
         $self->cache->set->($basename, \%info_hash)          }
           return $info;
 }  }
   
 sub _load {  sub _load {
Line 63 
Line 61 
         return $info;          return $info;
 }  }
   
 #sub cached  
 #{  
 #       my $self = shift;  
 #        my $which_info = shift;  
 #       my $file = shift;  
 #       my @args = @_;  
 #  
 #       if (@args) {  
 #               return $self->$which_info(@args),  
 #       }  
 #  
 #       return undef unless $which_info;  
 #       return $self->$which_info unless $file;  
 #  
 #       my $info = undef;  
 #  
 #       if (-e $file) {  
 #               #print "Reading meta file: $file\n";  
 #               $info = LoadFile($file);  
 #       }  
 #  
 #       unless ($info->{$which_info}) {  
 #               my $cur_info = $self->$which_info;  
 #  
 #               $info->{$which_info} = $cur_info;  
 #               DumpFile($file, $info);  
 #       }  
 #  
 #       if (defined $info->{$which_info}) {  
 #               return $info->{$which_info};  
 #       } else {  
 #               return $self->$which_info;  
 #       }  
 #}  
   
 1  sub save
   {
           my ($self, $file) = @_;
           my $basename = basename($file);
   
           $self->SUPER::save($file, @_);
   
           my %info_hash = %$self; # unbless
           $self->cache->set->($basename, \%info_hash)
   }

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>