[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [OSSTEST PATCH 09/60] history reporting (nfc): Provide cacheable_fn
Prep work. Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> --- sg-report-host-history | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/sg-report-host-history b/sg-report-host-history index f37dd4a2..90369ce4 100755 --- a/sg-report-host-history +++ b/sg-report-host-history @@ -181,20 +181,27 @@ END our $jqcachemisses = 0; our $jqtotal = 0; -sub cacheable_query ($$$) { - my ($q, $jr, $cachekey) = @_; +sub cacheable_fn ($$$) { + my ($jr, $cachekey, $fn) = @_; $jqtotal++; $cachekey = '%'.$cachekey; my $cached = $jr->{$cachekey}; if (!$cached) { $jqcachemisses++; - $q->execute($jr->{flight}, $jr->{job}); - $cached = $q->fetchrow_hashref(); + $cached = $fn->(); $jr->{$cachekey} = $cached; } return $cached; } +sub cacheable_query ($$$) { + my ($q, $jr, $cachekey) = @_; + cacheable_fn($jr, $cachekey, sub { + $q->execute($jr->{flight}, $jr->{job}); + return $q->fetchrow_hashref(); + }); +} + our %hosts; sub mainquery ($) { -- 2.11.0
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |