Browse files

Stop caching index details at the web level for now

  • Loading branch information...
1 parent 1778b46 commit fdb86c4d54fa120ac7c63b6cfc147e5f9e5eb3f7 @dgl committed Jul 24, 2012
Showing with 9 additions and 5 deletions.
  1. +9 −5 lib/WWW/CPANGrep/Search.pm
View
14 lib/WWW/CPANGrep/Search.pm
@@ -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);
}

0 comments on commit fdb86c4

Please sign in to comment.