Index: includes/forums/functions.php
===================================================================
--- includes/forums/functions.php	(revision 1891915)
+++ includes/forums/functions.php	(working copy)
@@ -1523,8 +1523,13 @@
 			'numberposts' => 1
 		);
 
-		// Get the most recent topic in this forum_id
-		$recent_topic = get_posts( $post_vars );
+		// Get the most recent topic in this forum_id	
+		$recent_topic = wp_cache_get( 'bbp_recent_topic_forum_' . $forum_id );
+		if ( false === $recent_topic ) {
+		    $recent_topic = get_posts( $post_vars );
+		    wp_cache_set( 'bbp_recent_topic_forum_' . $forum_id, $recent_topic );
+		}		
+		
 		if ( ! empty( $recent_topic ) ) {
 			$topic_id = $recent_topic[0]->ID;
 		}
@@ -1588,8 +1593,13 @@
 		if ( ! empty( $topic_ids ) ) {
 
 			// ...get the most recent reply from those topics...
-			$reply_id = bbp_forum_query_last_reply_id( $forum_id, $topic_ids );
-
+		    $topic_id_hash = md5( json_encode( $topic_ids ) );
+		    $reply_id = wp_cache_get( 'bbp_forum_query_last_reply_id_' . $forum_id . $topic_id_hash );
+		    if ( false === $reply_id ) {
+		        $reply_id = bbp_forum_query_last_reply_id( $forum_id, $topic_ids );
+		        wp_cache_set( 'bbp_forum_query_last_reply_id_' . $forum_id . $topic_id_hash, $reply_id );
+		    }
+		    
 			// ...and compare it to the most recent topic id...
 			$reply_id = ( $reply_id > max( $topic_ids ) ) ? $reply_id : max( $topic_ids );
 		}
@@ -1653,7 +1663,12 @@
 		// Don't count replies if the forum is a category
 		$topic_ids = bbp_forum_query_topic_ids( $forum_id );
 		if ( ! empty( $topic_ids ) ) {
-			$active_id = bbp_forum_query_last_reply_id( $forum_id, $topic_ids );
+		    $topic_id_hash = md5( json_encode( $topic_ids ) );
+		    $active_id = wp_cache_get( 'bbp_forum_query_last_reply_id_' . $forum_id . $topic_id_hash );
+		    if ( false === $active_id ) {
+		        $active_id = bbp_forum_query_last_reply_id( $forum_id, $topic_ids );
+		        wp_cache_set( 'bbp_forum_query_last_reply_id_' . $forum_id . $topic_id_hash, $active_id );
+		    }			
 			$active_id = $active_id > max( $topic_ids ) ? $active_id : max( $topic_ids );
 
 		// Forum has no topics
@@ -2268,8 +2283,11 @@
  *                        and forum id
  */
 function bbp_forum_query_topic_ids( $forum_id ) {
-	$topic_ids = bbp_get_public_child_ids( $forum_id, bbp_get_topic_post_type() );
-
+	$topic_ids = wp_cache_get( 'bbp_get_public_child_ids_forum_' . $forum_id );
+	if ( false === $topic_ids ) {
+	    $topic_ids = bbp_get_public_child_ids( $forum_id, bbp_get_topic_post_type() );
+	    wp_cache_set( 'bbp_get_public_child_ids_forum_' . $forum_id, $topic_ids );
+	}	
 	return (array) apply_filters( 'bbp_forum_query_topic_ids', $topic_ids, $forum_id );
 }
 
