Question about cleanup_deleted_caches()
-
Hello, I dont understand how the cron works.
In the cleanup_deleted_caches() function the DB query is selecting cache records where “expiration = date_i18n( ‘Y-m-d H:i:s’, 1 )”./** * Function called by a cron job to delete flushed or deleted caches from the transients API. * * @return void */ public function cleanup_deleted_caches() { global $wpdb; /** * How many caches should be cleanup in each run? * * Allows to change the number of cleaned up caches per cron run. * * @since 2020.2.0 * * @param int $limit The maximum number of cleaned up caches per cron run. */ $limit = (int) apply_filters( 'wp_rest_cache/max_cleanup_caches', 1000 ); $sql = "SELECT
cache_key
,deleted
FROM {$this->db_table_caches} WHEREexpiration
= %s ANDcleaned
= %d LIMIT %d"; // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared $caches = $wpdb->get_results( $wpdb->prepare( $sql, date_i18n( 'Y-m-d H:i:s', 1 ), 0, $limit ) ); if ( $caches ) { foreach ( $caches as $cache ) { $this->delete_cache( $cache->cache_key, $cache->deleted ); } }I dont understand how it can work ?
What is the probability that the expiration date is equal to the current date to the nearest second?Thanks for your help.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Question about cleanup_deleted_caches()’ is closed to new replies.