Index: src/wp-includes/meta.php
===================================================================
--- src/wp-includes/meta.php	(revision 31255)
+++ src/wp-includes/meta.php	(working copy)
@@ -785,55 +785,69 @@
 		return false;
 	}
 
-	$column = sanitize_key($meta_type . '_id');
+	$column = sanitize_key( $meta_type . '_id' );
 
-	if ( !is_array($object_ids) ) {
-		$object_ids = preg_replace('|[^0-9,]|', '', $object_ids);
-		$object_ids = explode(',', $object_ids);
+	if ( ! is_array( $object_ids ) ) {
+		$object_ids = preg_replace( '|[^0-9,]|', '', $object_ids );
+		$object_ids = explode( ',', $object_ids );
 	}
 
-	$object_ids = array_map('intval', $object_ids);
+	$object_ids = array_map( 'intval', $object_ids );
 
 	$cache_key = $meta_type . '_meta';
-	$ids = array();
-	$cache = array();
+	$ids       = array();
+	$cache     = array();
 	foreach ( $object_ids as $id ) {
 		$cached_object = wp_cache_get( $id, $cache_key );
-		if ( false === $cached_object )
+		if ( false === $cached_object ) {
 			$ids[] = $id;
-		else
-			$cache[$id] = $cached_object;
+		} else {
+			$cache[ $id ] = $cached_object;
+		}
 	}
 
-	if ( empty( $ids ) )
+	if ( empty( $ids ) ) {
 		return $cache;
+	}
 
-	// Get meta info
-	$id_list = join( ',', $ids );
-	$id_column = 'user' == $meta_type ? 'umeta_id' : 'meta_id';
-	$meta_list = $wpdb->get_results( "SELECT $column, meta_key, meta_value FROM $table WHERE $column IN ($id_list) ORDER BY $id_column ASC", ARRAY_A );
+	// Batch IDs when there are over 250
 
-	if ( !empty($meta_list) ) {
-		foreach ( $meta_list as $metarow) {
-			$mpid = intval($metarow[$column]);
-			$mkey = $metarow['meta_key'];
-			$mval = $metarow['meta_value'];
+	$batch_size = apply_filters( 'meta_cache_batch_size', 250 );
+	$chunks = array_chunk( $ids, $batch_size );
 
-			// Force subkeys to be array type:
-			if ( !isset($cache[$mpid]) || !is_array($cache[$mpid]) )
-				$cache[$mpid] = array();
-			if ( !isset($cache[$mpid][$mkey]) || !is_array($cache[$mpid][$mkey]) )
-				$cache[$mpid][$mkey] = array();
+	while ( ! empty( $chunks ) ) {
+		$batch = array_shift( $chunks );
 
-			// Add a value to the current pid/key:
-			$cache[$mpid][$mkey][] = $mval;
+		// Get meta info
+		$id_list   = join( ',', $batch );
+		$id_column = 'user' == $meta_type ? 'umeta_id' : 'meta_id';
+		$meta_list = $wpdb->get_results( "SELECT $column, meta_key, meta_value FROM $table WHERE $column IN ($id_list) ORDER BY $id_column ASC", ARRAY_A );
+
+		if ( ! empty( $meta_list ) ) {
+			foreach ( $meta_list as $metarow ) {
+				$mpid = intval( $metarow[ $column ] );
+				$mkey = $metarow['meta_key'];
+				$mval = $metarow['meta_value'];
+
+				// Force subkeys to be array type:
+				if ( ! isset( $cache[ $mpid ] ) || ! is_array( $cache[ $mpid ] ) ) {
+					$cache[ $mpid ] = array();
+				}
+				if ( ! isset( $cache[ $mpid ][ $mkey ] ) || ! is_array( $cache[ $mpid ][ $mkey ] ) ) {
+					$cache[ $mpid ][ $mkey ] = array();
+				}
+
+				// Add a value to the current pid/key:
+				$cache[ $mpid ][ $mkey ][] = $mval;
+			}
 		}
 	}
 
 	foreach ( $ids as $id ) {
-		if ( ! isset($cache[$id]) )
-			$cache[$id] = array();
-		wp_cache_add( $id, $cache[$id], $cache_key );
+		if ( ! isset( $cache[ $id ] ) ) {
+			$cache[ $id ] = array();
+		}
+		wp_cache_add( $id, $cache[ $id ], $cache_key );
 	}
 
 	return $cache;
Index: tests/phpunit/tests/cache.php
===================================================================
--- tests/phpunit/tests/cache.php	(revision 31255)
+++ tests/phpunit/tests/cache.php	(working copy)
@@ -305,4 +305,23 @@
 		// Make sure $fake_key is not stored
 		$this->assertFalse( wp_cache_get( $fake_key ) );
 	}
+
+	function test_meta_cache_update() {
+
+		add_filter('meta_cache_batch_size', array($this, 'set_meta_cache_batch_size'));
+
+		$postIDs = array('1','2','3','4');
+		$cache_results = array(
+			'1' => array(),
+			'2' => array(),
+			'3' => array(),
+			'4' => array()
+		);
+
+		$this->assertEquals( $cache_results, update_meta_cache('post', $postIDs) );
+	}
+
+	function set_meta_cache_batch_size($size) {
+		return 2;
+	}
 }
