Diff for /loncom/lonnet/perl/lonnet.pm between versions 1.541 and 1.542

version 1.541, 2004/09/15 20:08:34 version 1.542, 2004/09/17 02:40:35
Line 857  sub is_cached { Line 857  sub is_cached {
     my ($cache,$id,$name,$time) = @_;      my ($cache,$id,$name,$time) = @_;
     if (!$time) { $time=300; }      if (!$time) { $time=300; }
     if (!exists($$cache{$id.'.time'})) {      if (!exists($$cache{$id.'.time'})) {
  &load_cache_item($cache,$name,$id);   &load_cache_item($cache,$name,$id,$time);
     }      }
     if (!exists($$cache{$id.'.time'})) {      if (!exists($$cache{$id.'.time'})) {
 # &logthis("Didn't find $id");  # &logthis("Didn't find $id");
Line 934  EVALBLOCK Line 934  EVALBLOCK
 }  }
   
 sub load_cache_item {  sub load_cache_item {
     my ($cache,$name,$id)=@_;      my ($cache,$name,$id,$time)=@_;
     if ($disk_caching_disabled) { return; }      if ($disk_caching_disabled) { return; }
     my $starttime=&Time::HiRes::time();      my $starttime=&Time::HiRes::time();
 #    &logthis("Before Loading $name  for $id size is ".scalar(%$cache));  #    &logthis("Before Loading $name  for $id size is ".scalar(%$cache));
Line 958  sub load_cache_item { Line 958  sub load_cache_item {
  }   }
 #    &logthis("Initial load: $count");  #    &logthis("Initial load: $count");
     } else {      } else {
  my $hashref=thaw($hash{$id});   if (($$cache{$id.'.time'}+$time) < time) {
  $$cache{$id}=$hashref->{'item'};      $$cache{$id.'.time'}=$hash{$id.'.time'};
  $$cache{$id.'.time'}=$hash{$id.'.time'};      my $hashref=thaw($hash{$id});
       $$cache{$id}=$hashref->{'item'};
    }
     }      }
 EVALBLOCK  EVALBLOCK
         if ($@) {          if ($@) {
Line 4625  sub deversion { Line 4627  sub deversion {
   
 sub symbread {  sub symbread {
     my ($thisfn,$donotrecurse)=@_;      my ($thisfn,$donotrecurse)=@_;
     if (defined($ENV{'request.symbread.cached'})) {      my $cache_str='request.symbread.cached.'.$thisfn;
  return $ENV{'request.symbread.cached'};      if (defined($ENV{$cache_str})) { return $ENV{$cache_str}; }
     }  
 # no filename provided? try from environment  # no filename provided? try from environment
     unless ($thisfn) {      unless ($thisfn) {
         if ($ENV{'request.symb'}) {          if ($ENV{'request.symb'}) {
     $ENV{'request.symbread.cached'}=&symbclean($ENV{'request.symb'});      return $ENV{$cache_str}=&symbclean($ENV{'request.symb'});
     return $ENV{'request.symbread.cached'};  
  }   }
  $thisfn=$ENV{'request.filename'};   $thisfn=$ENV{'request.filename'};
     }      }
 # is that filename actually a symb? Verify, clean, and return  # is that filename actually a symb? Verify, clean, and return
     if ($thisfn=~/\_\_\_\d+\_\_\_(.*)$/) {      if ($thisfn=~/\_\_\_\d+\_\_\_(.*)$/) {
  if (&symbverify($thisfn,$1)) {   if (&symbverify($thisfn,$1)) {
     $ENV{'request.symbread.cached'}=&symbclean($thisfn);      return $ENV{$cache_str}=&symbclean($thisfn);
     return $ENV{'request.symbread.cached'};  
  }   }
     }      }
     $thisfn=declutter($thisfn);      $thisfn=declutter($thisfn);
Line 4662  sub symbread { Line 4661  sub symbread {
            unless ($syval=~/\_\d+$/) {             unless ($syval=~/\_\d+$/) {
        unless ($ENV{'form.request.prefix'}=~/\.(\d+)\_$/) {         unless ($ENV{'form.request.prefix'}=~/\.(\d+)\_$/) {
                   &appenv('request.ambiguous' => $thisfn);                    &appenv('request.ambiguous' => $thisfn);
   $ENV{'request.symbread.cached'}='';    return $ENV{$cache_str}='';
                   return '';  
                }                     }    
                $syval.=$1;                 $syval.=$1;
    }     }
Line 4710  sub symbread { Line 4708  sub symbread {
            }             }
         }          }
         if ($syval) {          if ($syval) {
     $ENV{'request.symbread.cached'}=&symbclean($syval.'___'.$thisfn);      return $ENV{$cache_str}=&symbclean($syval.'___'.$thisfn);
     return $ENV{'request.symbread.cached'};  
         }          }
     }      }
     &appenv('request.ambiguous' => $thisfn);      &appenv('request.ambiguous' => $thisfn);
     $ENV{'request.symbread.cached'}='';      return $ENV{$cache_str}='';
     return '';  
 }  }
   
 # ---------------------------------------------------------- Return random seed  # ---------------------------------------------------------- Return random seed

Removed from v.1.541  
changed lines
  Added in v.1.542


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