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

albertel lon-capa-cvs@mail.lon-capa.org
Mon, 14 Feb 2005 03:11:07 -0000


albertel		Sun Feb 13 22:11:07 2005 EDT

  Modified files:              (Branch: version_1_3_X_memcached)
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - improve debugability of the caching code
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.587.2.3.2.6 loncom/lonnet/perl/lonnet.pm:1.587.2.3.2.7
--- loncom/lonnet/perl/lonnet.pm:1.587.2.3.2.6	Sun Feb 13 21:22:25 2005
+++ loncom/lonnet/perl/lonnet.pm	Sun Feb 13 22:11:07 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.587.2.3.2.6 2005/02/14 02:22:25 albertel Exp $
+# $Id: lonnet.pm,v 1.587.2.3.2.7 2005/02/14 03:11:07 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1028,8 +1028,8 @@
 my $kicks=0;
 my $hits=0;
 sub devalidate_cache_new {
-    my ($name,$id) = @_;
-    if (0) { &Apache::lonnet::logthis("deleting $name:$id"); }
+    my ($name,$id,$debug) = @_;
+    if ($debug) { &Apache::lonnet::logthis("deleting $name:$id"); }
     $id=&escape($name.':'.$id);
     $memcache->delete($id);
     delete($remembered{$id});
@@ -1038,7 +1038,6 @@
 
 sub is_cached_new {
     my ($name,$id,$debug) = @_;
-    $debug=0;
     $id=&escape($name.':'.$id);
     if (exists($remembered{$id})) {
 	if ($debug) { &Apache::lonnet::logthis("Earyl return $id of $remembered{$id} "); }
@@ -1051,7 +1050,7 @@
 	if ($debug) { &Apache::lonnet::logthis("getting $id is not defined"); }
 	return (undef,undef);
     }
-    &make_room($id,$value);
+    &make_room($id,$value,$debug);
     if ($value eq '__undef__') {
 	if ($debug) { &Apache::lonnet::logthis("getting $id is __undef__"); }
 	return (undef,1);
@@ -1062,7 +1061,6 @@
 
 sub do_cache_new {
     my ($name,$id,$value,$time,$debug) = @_;
-    $debug=0;
     $id=&escape($name.':'.$id);
     my $setvalue=$value;
     if (!defined($setvalue)) {
@@ -1070,13 +1068,12 @@
     }
     if ($debug) { &Apache::lonnet::logthis("Setting $id to $value"); }
     $memcache->set($id,$setvalue,300);
-    &make_room($id,$value);
+    &make_room($id,$value,$debug);
     return $value;
 }
 
 sub make_room {
-    my ($id,$value)=@_;
-    my $debug=0;
+    my ($id,$value,$debug)=@_;
     $remembered{$id}=$value;
     $accessed{$id}=[&gettimeofday()];
     if (scalar(keys(%remembered)) <= $to_remember) { return; }