Title: Flushing Object Cache Needed when Comment Posted
Last modified: October 10, 2023

---

# Flushing Object Cache Needed when Comment Posted

 *  Resolved [Rhapsody348](https://wordpress.org/support/users/rhapsody348/)
 * (@rhapsody348)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/flushing-object-cache-needed-when-comment-posted/)
 * 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:
 *     ```wp-block-code
       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](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fflushing-object-cache-needed-when-comment-posted%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Till Krüss](https://wordpress.org/support/users/tillkruess/)
 * (@tillkruess)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/flushing-object-cache-needed-when-comment-posted/#post-17114529)
 * Yes, `wp_cache_flush()`.
 *  Thread Starter [Rhapsody348](https://wordpress.org/support/users/rhapsody348/)
 * (@rhapsody348)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/flushing-object-cache-needed-when-comment-posted/#post-17114644)
 * This works great – Thanks very much!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Flushing Object Cache Needed when Comment Posted’ is closed to new replies.

 * ![](https://ps.w.org/redis-cache/assets/icon-256x256.gif?rev=2568513)
 * [Redis Object Cache](https://wordpress.org/plugins/redis-cache/)
 * [Support Threads](https://wordpress.org/support/plugin/redis-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/redis-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/redis-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/redis-cache/reviews/)

## Tags

 * [flush cache](https://wordpress.org/support/topic-tag/flush-cache/)

 * 3 replies
 * 3 participants
 * Last reply from: [Rhapsody348](https://wordpress.org/support/users/rhapsody348/)
 * Last activity: [2 years, 7 months ago](https://wordpress.org/support/topic/flushing-object-cache-needed-when-comment-posted/#post-17114644)
 * Status: resolved