From: erickson Date: Thu, 21 Aug 2008 13:37:22 +0000 (+0000) Subject: forcing cache timeout on staged search cacheing (*sigh*). added some logging for... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=0789d567718fa972e12c39b78420ce32ba5a1112;p=Evergreen.git forcing cache timeout on staged search cacheing (*sigh*). added some logging for timed out and 0-hit searches. git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_2_3@10386 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm b/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm index 6dd4671ee8..e8d1e12f15 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm @@ -703,6 +703,7 @@ sub staged_search { $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 @@ sub staged_search { $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 @@ sub cache_staged_search_page { $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 {