--- loncom/lonnet/perl/lonnet.pm 2004/09/15 20:44:05 1.523.2.3 +++ loncom/lonnet/perl/lonnet.pm 2004/09/17 02:41:21 1.523.2.4 @@ -1,7 +1,7 @@ # The LearningOnline Network # TCP networking package # -# $Id: lonnet.pm,v 1.523.2.3 2004/09/15 20:44:05 albertel Exp $ +# $Id: lonnet.pm,v 1.523.2.4 2004/09/17 02:41:21 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -857,7 +857,7 @@ sub is_cached { my ($cache,$id,$name,$time) = @_; if (!$time) { $time=300; } if (!exists($$cache{$id.'.time'})) { - &load_cache_item($cache,$name,$id); + &load_cache_item($cache,$name,$id,$time); } if (!exists($$cache{$id.'.time'})) { # &logthis("Didn't find $id"); @@ -934,7 +934,7 @@ EVALBLOCK } sub load_cache_item { - my ($cache,$name,$id)=@_; + my ($cache,$name,$id,$time)=@_; if ($disk_caching_disabled) { return; } my $starttime=&Time::HiRes::time(); # &logthis("Before Loading $name for $id size is ".scalar(%$cache)); @@ -958,9 +958,11 @@ sub load_cache_item { } # &logthis("Initial load: $count"); } else { - my $hashref=thaw($hash{$id}); - $$cache{$id}=$hashref->{'item'}; - $$cache{$id.'.time'}=$hash{$id.'.time'}; + if (($$cache{$id.'.time'}+$time) < time) { + $$cache{$id.'.time'}=$hash{$id.'.time'}; + my $hashref=thaw($hash{$id}); + $$cache{$id}=$hashref->{'item'}; + } } EVALBLOCK if ($@) { @@ -4590,22 +4592,19 @@ sub deversion { sub symbread { my ($thisfn,$donotrecurse)=@_; - if (defined($ENV{'request.symbread.cached'})) { - return $ENV{'request.symbread.cached'}; - } + my $cache_str='request.symbread.cached.'.$thisfn; + if (defined($ENV{$cache_str})) { return $ENV{$cache_str}; } # no filename provided? try from environment unless ($thisfn) { if ($ENV{'request.symb'}) { - $ENV{'request.symbread.cached'}=&symbclean($ENV{'request.symb'}); - return $ENV{'request.symbread.cached'}; + return $ENV{$cache_str}=&symbclean($ENV{'request.symb'}); } $thisfn=$ENV{'request.filename'}; } # is that filename actually a symb? Verify, clean, and return if ($thisfn=~/\_\_\_\d+\_\_\_(.*)$/) { if (&symbverify($thisfn,$1)) { - $ENV{'request.symbread.cached'}=&symbclean($thisfn); - return $ENV{'request.symbread.cached'}; + return $ENV{$cache_str}=&symbclean($thisfn); } } $thisfn=declutter($thisfn); @@ -4627,8 +4626,7 @@ sub symbread { unless ($syval=~/\_\d+$/) { unless ($ENV{'form.request.prefix'}=~/\.(\d+)\_$/) { &appenv('request.ambiguous' => $thisfn); - $ENV{'request.symbread.cached'}=''; - return ''; + return $ENV{$cache_str}=''; } $syval.=$1; } @@ -4675,13 +4673,11 @@ sub symbread { } } if ($syval) { - $ENV{'request.symbread.cached'}=&symbclean($syval.'___'.$thisfn); - return $ENV{'request.symbread.cached'}; + return $ENV{$cache_str}=&symbclean($syval.'___'.$thisfn); } } &appenv('request.ambiguous' => $thisfn); - $ENV{'request.symbread.cached'}=''; - return ''; + return $ENV{$cache_str}=''; } # ---------------------------------------------------------- Return random seed