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

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 05 Dec 2002 23:27:46 -0000


albertel		Thu Dec  5 18:27:46 2002 EDT

  Modified files:              
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - if the student doen't even have a resourcedata.db remeber this and don't keep trying to get one, this is a big speed win
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.307 loncom/lonnet/perl/lonnet.pm:1.308
--- loncom/lonnet/perl/lonnet.pm:1.307	Thu Dec  5 18:13:54 2002
+++ loncom/lonnet/perl/lonnet.pm	Thu Dec  5 18:27:46 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.307 2002/12/05 23:13:54 albertel Exp $
+# $Id: lonnet.pm,v 1.308 2002/12/05 23:27:46 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -80,7 +80,8 @@
 qw(%perlvar %hostname %homecache %badServerCache %hostip %iphost %spareid %hostdom 
    %libserv %pr %prp %metacache %packagetab %titlecache 
    %courselogs %accesshash $processmarker $dumpcount 
-   %coursedombuf %coursehombuf %courseresdatacache %domaindescription);
+   %coursedombuf %coursehombuf %courseresdatacache 
+   %studentresdatacache %domaindescription);
 use IO::Socket;
 use GDBM_File;
 use Apache::Constants qw(:common :http);
@@ -2848,25 +2849,32 @@
 	    my $courselevelm=$courseid.'.'.$mapparm;
 
 # ----------------------------------------------------------- first, check user
-	    my %resourcedata=&get('resourcedata',
-				  [$courselevelr,$courselevelm,$courselevel],
-				 $udom,$uname);
-	    my ($tmp)=keys(%resourcedata);
-	    if (($tmp!~/^error\:/) && ($tmp!~/^con_lost/)) {
-		if ($resourcedata{$courselevelr}) {
-		    return $resourcedata{$courselevelr}; }
-		if ($resourcedata{$courselevelm}) {
-		    return $resourcedata{$courselevelm}; }
-		if ($resourcedata{$courselevel}) {
-		    return $resourcedata{$courselevel}; }
-	    } else {
-		if ($tmp!~/No such file/) {
-		    &logthis("<font color=blue>WARNING:".
-			     " Trying to get resource data for ".
-			     $uname." at ".$udom.": ".
-			     $tmp."</font>");
-		} elsif ($tmp =~ /^(con_lost|no_such_host)/) {
-		  return $tmp;
+	    #most student don't have any data set, check if there is some data
+            #every thirty minutes
+	    if (!exists($studentresdatacache{$uname.'_'.$udom})
+		|| $studentresdatacache{$uname.'_'.$udom} > (time+1800)) {
+		my %resourcedata=&get('resourcedata',
+				      [$courselevelr,$courselevelm,$courselevel],
+				      $udom,$uname);
+		my ($tmp)=keys(%resourcedata);
+		if (($tmp!~/^error\:/) && ($tmp!~/^con_lost/)) {
+		    if ($resourcedata{$courselevelr}) {
+			return $resourcedata{$courselevelr}; }
+		    if ($resourcedata{$courselevelm}) {
+			return $resourcedata{$courselevelm}; }
+		    if ($resourcedata{$courselevel}) {
+			return $resourcedata{$courselevel}; }
+		} else {
+		    if ($tmp!~/No such file/) {
+			&logthis("<font color=blue>WARNING:".
+				 " Trying to get resource data for ".
+				 $uname." at ".$udom.": ".
+				 $tmp."</font>");
+		    } elsif ($tmp=~/error:No such file/) {
+			$studentresdatacache{$uname.'_'.$udom}=time;
+		    } elsif ($tmp =~ /^(con_lost|no_such_host)/) {
+			return $tmp;
+		    }
 		}
 	    }