[LON-CAPA-cvs] cvs: loncom /lonnet/perl lonnet.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Fri, 17 Sep 2004 02:40:35 -0000
albertel Thu Sep 16 22:40:35 2004 EDT
Modified files:
/loncom/lonnet/perl lonnet.pm
Log:
- okay cache value returned by value passed in, fixes a visual problem in printing
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.541 loncom/lonnet/perl/lonnet.pm:1.542
--- loncom/lonnet/perl/lonnet.pm:1.541 Wed Sep 15 16:08:34 2004
+++ loncom/lonnet/perl/lonnet.pm Thu Sep 16 22:40:35 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.541 2004/09/15 20:08:34 albertel Exp $
+# $Id: lonnet.pm,v 1.542 2004/09/17 02:40:35 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -857,7 +857,7 @@
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 @@
}
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 @@
}
# &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 ($@) {
@@ -4625,22 +4627,19 @@
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);
@@ -4662,8 +4661,7 @@
unless ($syval=~/\_\d+$/) {
unless ($ENV{'form.request.prefix'}=~/\.(\d+)\_$/) {
&appenv('request.ambiguous' => $thisfn);
- $ENV{'request.symbread.cached'}='';
- return '';
+ return $ENV{$cache_str}='';
}
$syval.=$1;
}
@@ -4710,13 +4708,11 @@
}
}
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