[LON-CAPA-cvs] cvs: loncom /lonnet/perl lonnet.pm

matthew lon-capa-cvs@mail.lon-capa.org
Wed, 11 Jun 2003 14:41:24 -0000


matthew		Wed Jun 11 10:41:24 2003 EDT

  Modified files:              
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  EXT: encapsulate the cache status with
  &clear_EXT_cache_status, &EXT_cache_status, and &EXT_cache_set
  caches (actually, the existance of resourcedata for a student) are now set
  on a PER STUDENT basis.  This causes the chart to actually display correct
  data for every student instead of assuming the data is the same for all the
  students.
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.378 loncom/lonnet/perl/lonnet.pm:1.379
--- loncom/lonnet/perl/lonnet.pm:1.378	Tue Jun 10 14:17:34 2003
+++ loncom/lonnet/perl/lonnet.pm	Wed Jun 11 10:41:24 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.378 2003/06/10 18:17:34 matthew Exp $
+# $Id: lonnet.pm,v 1.379 2003/06/11 14:41:24 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3185,8 +3185,32 @@
     return undef;
 }
 
-# --------------------------------------------------------- Value of a Variable
+#
+# EXT resource caching routines
+#
+
+sub clear_EXT_cache_status {
+    &delenv('cache.');
+}
+
+sub EXT_cache_status {
+    my ($target_domain,$target_user) = @_;
+    my $cachename = 'cache.'.$target_user.'.'.$target_domain;
+    if (exists($ENV{$cachename}) && ($ENV{$cachename}+1800) > time) {
+        # We know already the user has no data
+        return 1;
+    } else {
+        return 0;
+    }
+}
 
+sub EXT_cache_set {
+    my ($target_domain,$target_user) = @_;
+    my $cachename = 'cache.'.$target_user.'.'.$target_domain;
+    &appenv($cachename => time);
+}
+
+# --------------------------------------------------------- Value of a Variable
 sub EXT {
     my ($varname,$symbparm,$udom,$uname,$usection)=@_;
 
@@ -3321,11 +3345,9 @@
 	    my $courselevelm=$courseid.'.'.$mapparm;
 
 # ----------------------------------------------------------- first, check user
-	    #most student don't have any data set, check if there is some data
+	    #most student don\'t have any data set, check if there is some data
             #every thirty minutes
-	    if (!
-		(exists($ENV{'cache.studentresdata'})
-		    && (($ENV{'cache.studentresdata'}+1800) > time))) {
+	    if (! &EXT_cache_status($udom,$uname)) {
 		my %resourcedata=&get('resourcedata',
 				      [$courselevelr,$courselevelm,$courselevel],
 				      $udom,$uname);
@@ -3344,9 +3366,7 @@
 				 $uname." at ".$udom.": ".
 				 $tmp."</font>");
 		    } elsif ($tmp=~/error:No such file/) {
-			$ENV{'cache.studentresdata'}=time;
-			&appenv(('cache.studentresdata'=>
-				 $ENV{'cache.studentresdata'}));
+                        &EXT_cache_set($udom,$uname);
 		    } elsif ($tmp =~ /^(con_lost|no_such_host)/) {
 			return $tmp;
 		    }