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

albertel lon-capa-cvs@mail.lon-capa.org
Sat, 04 Oct 2003 02:34:02 -0000


albertel		Fri Oct  3 22:34:02 2003 EDT

  Modified files:              
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - converted homecache to use common caching infrastructure
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.425 loncom/lonnet/perl/lonnet.pm:1.426
--- loncom/lonnet/perl/lonnet.pm:1.425	Fri Oct  3 22:27:02 2003
+++ loncom/lonnet/perl/lonnet.pm	Fri Oct  3 22:34:01 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.425 2003/10/04 02:27:02 albertel Exp $
+# $Id: lonnet.pm,v 1.426 2003/10/04 02:34:01 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -586,9 +586,9 @@
 sub homeserver {
     my ($uname,$udom,$ignoreBadCache)=@_;
     my $index="$uname:$udom";
-    if ($homecache{$index}) { 
-        return "$homecache{$index}"; 
-    }
+
+    my ($result,$cached)=&is_cached(\%homecache,$index,'home',86400);
+    if (defined($cached)) { return $result; }
     my $tryserver;
     foreach $tryserver (keys %libserv) {
         next if ($ignoreBadCache ne 'true' && 
@@ -596,8 +596,7 @@
 	if ($hostdom{$tryserver} eq $udom) {
            my $answer=reply("home:$udom:$uname",$tryserver);
            if ($answer eq 'found') { 
-              $homecache{$index}=$tryserver;
-              return $tryserver; 
+	       return &do_cache(\%homecache,$index,$tryserver,'home');
            } elsif ($answer eq 'no_host') {
 	       $badServerCache{$tryserver}=1;
            }