Skip to content

Commit

Permalink
feat(cloud): set expiration for job data after completion or failure.
Browse files Browse the repository at this point in the history
Fixes elegantthemes/Divi#27310

build: [release]
  • Loading branch information
lots0logs committed Mar 18, 2022
1 parent 28ca89b commit be1e780
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public static function done( Job $job ): void {
self::_dbTry( 'lrem', $queue->__running(), $job->id, 0 );
self::_dbTry( 'lpush', $queue->__completed(), $job->id );

// Set expiration for job data after which it will automatically be removed by redis
self::_dbTry( 'expire', $queue->__key( 'jobs', $job->id ), 60 * 60 * 12 );

// Don't allow completed list to grow beyond 200 entries.
self::_dbTry( 'ltrim', $queue->__completed(), 0, 199 );
}
Expand All @@ -64,6 +67,9 @@ public static function error( Job $job ): void {
self::_dbTry( 'lrem', $queue->__running(), $job->id, 0 );
self::_dbTry( 'lpush', $queue->__failed(), $job->id );

// Set expiration for job data after which it will automatically be removed by redis
self::_dbTry( 'expire', $queue->__key( 'jobs', $job->id ), 60 * 60 * 12 );

// Don't allow failed list to grow beyond 200 entries.
self::_dbTry( 'ltrim', $queue->__failed(), 0, 199 );
}
Expand Down

0 comments on commit be1e780

Please sign in to comment.