Skip to content

Commit

Permalink
Fix update remove expiration from status key and use setex so atomic
Browse files Browse the repository at this point in the history
  • Loading branch information
daneren2005 committed Sep 7, 2021
1 parent 71e972d commit 4eb6a88
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions lib/Resque/Job/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ public static function create($id)
);

$key = 'job:' . $id . ':status';
Resque::redis()->set($key, json_encode($statusPacket));
// Don't keep statuses forever
Resque::redis()->expire($key, 86400);
Resque::redis()->setex($key, 86400, json_encode($statusPacket));
}

/**
Expand Down Expand Up @@ -104,12 +102,7 @@ public function update($status)
$statusPacket['updated'] = time();
$statusPacket[self::statusToString($status)] = time();

Resque::redis()->set((string)$this, json_encode($statusPacket));

// Expire the status for completed jobs after 24 hours
if(in_array($status, self::$completeStatuses)) {
Resque::redis()->expire((string)$this, 86400);
}
Resque::redis()->setex((string)$this, 86400, json_encode($statusPacket));
}

/**
Expand Down

0 comments on commit 4eb6a88

Please sign in to comment.