clean_comment_cache()WP 2.3.0

Removes a comment from the object cache.

Hooks from the function

Return

null. Nothing (null).

Usage

clean_comment_cache( $ids );
$ids(int|array) (required)
Comment ID or an array of comment IDs to remove from cache.

Examples

0

#1 Clear cache posts

Let's say we're editing comment 25 and we need to clear its cache:

clean_comment_cache( 25 );

Let's clear the cache of comments 25 and 34:

clean_comment_cache( [ 25, 34 ] );

Changelog

Since 2.3.0 Introduced.

clean_comment_cache() code WP 6.5.2

function clean_comment_cache( $ids ) {
	$comment_ids = (array) $ids;
	wp_cache_delete_multiple( $comment_ids, 'comment' );
	foreach ( $comment_ids as $id ) {
		/**
		 * Fires immediately after a comment has been removed from the object cache.
		 *
		 * @since 4.5.0
		 *
		 * @param int $id Comment ID.
		 */
		do_action( 'clean_comment_cache', $id );
	}

	wp_cache_set_comments_last_changed();
}