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

Commit

Permalink
Allow redis background saves
Browse files Browse the repository at this point in the history
Don't die if redis is already saving, simply wait a bit and retry.
  • Loading branch information
seveas committed Apr 23, 2014
1 parent 1b4c494 commit 85667a4
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/WWW/CPANGrep/Index.pm
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,18 @@ sub index {
my $redis_conn = (tied %{$self->redis})->{_conn};
eval { $redis_conn->rename("cpangrep:slabs", "cpangrep:slabs-old") };
$redis_conn->rename("new-index", "cpangrep:slabs");
$redis_conn->save;
eval {
$redis_conn->save;
1;
} or do {
my $err = $@;
if($err !~ /Background save is already in progress/) {
die $err;
}
warn $err;
sleep 5;
$redis_conn->save;
};

for my $slab(@{$self->redis->{"cpangrep:slabs-old"}}) {
unlink $self->slab_dir . "/" . $slab;
Expand Down

0 comments on commit 85667a4

Please sign in to comment.