Flushing Object Cache Needed when Comment Posted

[ad_1]

When a comment is posted, the recent comments widget is not updated unless I manually flush the object cache. Is there a function I can use when the comment posted hook is triggered, or is there another recommended approach so the comment is pushed to the widget? Something such as:

function cm_flush_object_cache( $comment_ID, $comment_approved ) {
	if( 1 === $comment_approved ){
	  //object flush cache logic goes here
	}
}
add_action( 'comment_post', 'cm_flush_object_cache', 10, 2 );

The page I need help with: [log in to see the link]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer