[open-ils-commits] r10386 - branches/rel_1_2_3/Open-ILS/src/perlmods/OpenILS/Application/Search

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Aug 21 09:37:23 EDT 2008


Author: erickson
Date: 2008-08-21 09:37:22 -0400 (Thu, 21 Aug 2008)
New Revision: 10386

Modified:
   branches/rel_1_2_3/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm
Log:
forcing cache timeout on staged search cacheing (*sigh*).  added some logging for timed out and 0-hit searches.

Modified: branches/rel_1_2_3/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm
===================================================================
--- branches/rel_1_2_3/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm	2008-08-21 04:12:00 UTC (rev 10385)
+++ branches/rel_1_2_3/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm	2008-08-21 13:37:22 UTC (rev 10386)
@@ -703,6 +703,7 @@
     $method .= '.staff' if $self->api_name =~ /staff$/;
     $method .= '.atomic';
 
+    my $search_duration;
     my $user_offset = $search_hash->{offset} || 0; # user-specified offset
     my $user_limit = $search_hash->{limit} || 10;
     $user_offset = ($user_offset >= 0) ? $user_offset : 0;
@@ -750,9 +751,23 @@
             $search_hash->{skip_check} = $page * $superpage_size;
             my $start = time;
             $results = $U->storagereq($method, %$search_hash);
-            $logger->info("staged search: DB call took ".(time - $start)." seconds");
+            $search_duration = time - $start;
+            $logger->info("staged search: DB call took $search_duration seconds");
             $summary = shift(@$results);
 
+            unless($summary) {
+                $logger->info("search timed out: duration=$search_duration: params=".
+                    OpenSRF::Utils::JSON->perl2JSON($search_hash));
+                return {count => 0};
+            }
+
+            my $hc = $summary->{estimated_hit_count} || $summary->{visible};
+            if($hc == 0) {
+                $logger->info("search returned 0 results: duration=$search_duration: params=".
+                    OpenSRF::Utils::JSON->perl2JSON($search_hash));
+                return {count => 0};
+            }
+
             # Create backwards-compatible result structures
             if($self->api_name =~ /biblio/) {
                 $results = [map {[$_->{id}]} @$results];
@@ -827,7 +842,7 @@
     $logger->info("staged search: cached with key=$key, superpage=$page, estimated=".
         $summary->{estimated_hit_count}.", visible=".$summary->{visible});
 
-    $cache->put_cache($key, $data);
+    $cache->put_cache($key, $data, $cache_timeout);
 }
 
 sub search_cache {



More information about the open-ils-commits mailing list