[open-ils-commits] r10389 -
trunk/Open-ILS/src/perlmods/OpenILS/Application/Search
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Aug 21 09:39:45 EDT 2008
Author: erickson
Date: 2008-08-21 09:39:44 -0400 (Thu, 21 Aug 2008)
New Revision: 10389
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Search/Authority.pm
trunk/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. removed warns and replaced with logger calls
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Search/Authority.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Search/Authority.pm 2008-08-21 13:38:55 UTC (rev 10388)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Search/Authority.pm 2008-08-21 13:39:44 UTC (rev 10389)
@@ -154,11 +154,10 @@
my $class = $req->[0];
my $term = $req->[1];
next unless $class and $term;
- warn "Sending authority request for $class : $term\n";
+ $logger->info("Sending authority request for $class : $term");
my $fr = $session->request("open-ils.storage.authority.$class.see_from.controlled.atomic",$term, 10)->gather(1);
my $al = $session->request("open-ils.storage.authority.$class.see_also_from.controlled.atomic",$term, 10)->gather(1);
- warn "Flattening $class : $term\n";
$response->{$class} = {} unless exists $response->{$class};
$response->{$class}->{$term} = _auth_flatten( $term, $fr, $al, 1 );
@@ -180,7 +179,7 @@
my $class = $req->[0];
my $term = $req->[1];
next unless $class and $term;
- warn "Sending authority request for $class : $term\n";
+ $logger->info("Sending authority request for $class : $term");
my $freq = $session->request("open-ils.storage.authority.$class.see_from.controlled.atomic",$term, 10);
my $areq = $session->request("open-ils.storage.authority.$class.see_also_from.controlled.atomic",$term, 10);
@@ -189,7 +188,6 @@
my $trm = $lastr->[1];
my $fr = $lastr->[2];
my $al = $lastr->[3];
- warn "Flattening $class : $term\n";
$response->{$cls} = {} unless exists $response->{$cls};
$response->{$cls}->{$trm} = _auth_flatten( $trm, $fr, $al, 1 );
}
@@ -205,7 +203,6 @@
my $trm = $lastr->[1];
my $fr = $lastr->[2];
my $al = $lastr->[3];
- warn "Flattening $cls : $trm\n";
$response->{$cls} = {} unless exists $response->{$cls};
$response->{$cls}->{$trm} = _auth_flatten( $trm, $fr, $al, 1);
}
@@ -244,7 +241,7 @@
$logger->debug("authority data not found in cache.. fetching from storage");
- warn "Sending authority request for $class : $term\n";
+ $logger->info("Sending authority request for $class : $term");
my $freq = $session->request("open-ils.storage.authority.$class.see_from.controlled.atomic",$term, 10);
my $areq = $session->request("open-ils.storage.authority.$class.see_also_from.controlled.atomic",$term, 10);
my $fr = $freq->gather(1);
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm 2008-08-21 13:38:55 UTC (rev 10388)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm 2008-08-21 13:39:44 UTC (rev 10389)
@@ -764,6 +764,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;
@@ -820,9 +821,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];
@@ -922,7 +937,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