X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=web_ui.pl;h=19f435f54c900469b416b39627a0da38afcbc365;hb=52ebace1238d879380f36f2d80dec639f79e2265;hp=21673c422b894a3ee1d40f5f6514c0a1a3ae2859;hpb=534fa8138fb554eef0ac07ca8816bf4819f3cb54;p=APKPM.git diff --git a/web_ui.pl b/web_ui.pl index 21673c4..19f435f 100755 --- a/web_ui.pl +++ b/web_ui.pl @@ -96,7 +96,7 @@ get '/table/:table' => sub { # generate result as Store_sql does - my @c = split(/\s+/, $redis->get("pg.$table")); + my @c = split(/\s+/, $redis->get("columns.$table")); my ($hash_col) = grep { $c[$_] eq 'h' } 0 .. $#c; $ret = { @@ -143,26 +143,25 @@ sub _gearman_redis { warn "# _gearman_redis $key [$timeout s]"; my $redis = Redis->new; - my $ret; + my $json; - if ( $ret = $redis->get($key) ) { + if ( $json = $redis->get($key) ) { warn "redis hit $key\n"; } else { $gearman->timeout($timeout); - $ret = $gearman->req( 'SUBMIT_JOB', $job, '', $params ); - die "no result for $params" unless $ret; - - $redis->set($key => $ret); + $json = $gearman->req( 'SUBMIT_JOB', $job, '', $params ); + die "no result for $params" unless $json; } - $redis->expire($key => 60); # refresh redis key timeout - - $ret = Mojo::JSON->new->decode( $ret ); + my $ret = Mojo::JSON->new->decode( $json ); if ( ! exists $ret->{error} && ref $ret->{columns} ne 'ARRAY' ) { $ret->{error} = 'query run longer than ' . $gearman->timeout . ' s timeout'; } + $redis->set($key => $json); + $redis->expire($key => 60); # refresh redis key timeout + return $ret; }