Skip to content
This repository has been archived by the owner on Apr 12, 2020. It is now read-only.

Commit

Permalink
Stop caching index details at the web level for now
Browse files Browse the repository at this point in the history
  • Loading branch information
dgl committed Jul 24, 2012
1 parent 1778b46 commit fdb86c4
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/WWW/CPANGrep/Search.pm
Original file line number Diff line number Diff line change
Expand Up @@ -219,17 +219,21 @@ sub search {

sub _find_slabs {
my($self, $redis) = @_;
# XXX: This is pretty small with a small number of web workers, but can do
# better (make the matcher more intelligent?)
state $dist_slab_map = { @{$redis->hgetall("cpangrep:dists")->recv} };
state $all_slabs = $redis->lrange($config->{"key.slabs"}, 0, -1)->recv;
state $slab_id_map = { map +($all_slabs->[$_] => $_), 0 .. $#$all_slabs };
# XXX: Store a generation of the index somewhere so these can be cached.
my $dist_slab_map;
my $all_slabs = $redis->lrange($config->{"key.slabs"}, 0, -1)->recv;
my $slab_id_map = { map +($all_slabs->[$_] => $_), 0 .. $#$all_slabs };

my $slabs = set(@$all_slabs);

for my $option(values $self->_options) {
if(!$option->{negate}) {
if($option->{type} eq 'dist') {

# XXX: This is pretty small with a small number of web workers, but can do
# better (make the matcher more intelligent?)
$dist_slab_map ||= { @{$redis->hgetall("cpangrep:dists")->recv} };

$slabs = set(map $dist_slab_map->{$_}, grep $_ =~ $option->{re}, keys
$dist_slab_map)->intersection($slabs);
}
Expand Down

0 comments on commit fdb86c4

Please sign in to comment.