Skip to content

Commit

Permalink
refactor lrc filter initiation
Browse files Browse the repository at this point in the history
  • Loading branch information
Khadreal committed Feb 12, 2025
1 parent c7b1697 commit af40278
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,7 @@ public function delete_old_rows() {
return false;
}

/**
* Filters the interval (in months) to determine when Below The Fold entry is considered 'old'.
* Old LRC entries are eligible for deletion. By default, LRC entry is considered old if it hasn't been accessed in the last month.
*
* @param int $delete_interval The interval in months after which LRC entry is considered old. Default is 1 month.
*/
$delete_interval = (int) apply_filters( 'rocket_lrc_cleanup_interval', 1 );

if ( $delete_interval <= 0 ) {
return false;
}
$delete_interval = $this->cleanup_interval;

$prefixed_table_name = $db->prefix . $this->table_name;
$query = "DELETE FROM `$prefixed_table_name` WHERE status = 'failed' OR `last_accessed` <= date_sub(now(), interval $delete_interval month)";
Expand Down
15 changes: 14 additions & 1 deletion inc/Engine/Optimization/LazyRenderContent/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,20 @@ public function table(): TableInterface {
* @return QueriesInterface
*/
public function queries(): QueriesInterface {
return $this->queries;

/**
* Filters the interval (in months) to determine when Below The Fold entry is considered 'old'.
* Old LRC entries are eligible for deletion. By default, LRC entry is considered old if it hasn't been accessed in the last month.
*
* @param int $delete_interval The interval in months after which LRC entry is considered old. Default is 1 month.
*/
$delete_interval = wpm_apply_filters_typed( 'integer', 'rocket_lrc_cleanup_interval', 1 );

if ( $delete_interval <= 0 ) {
return $this->queries;
}

return $this->queries->set_cleanup_interval( $delete_interval ); // @phpstan-ignore-line
}

/**
Expand Down

0 comments on commit af40278

Please sign in to comment.