From be1e780bdacc5a7a6226b386f6926563d7a67d5b Mon Sep 17 00:00:00 2001 From: Dustin Falgout Date: Fri, 18 Mar 2022 18:10:28 -0500 Subject: [PATCH] feat(cloud): set expiration for job data after completion or failure. Fixes elegantthemes/Divi#27310 build: [release] --- src/Queue.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Queue.php b/src/Queue.php index 874ca56..83e0a46 100644 --- a/src/Queue.php +++ b/src/Queue.php @@ -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 ); } @@ -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 ); }