W3cubDocs

/WordPress

cache_users( array $user_ids )

Retrieve info for user lists to prevent multiple queries by get_userdata()

Parameters

$user_ids

(array) (Required) User ID numbers list

Source

File: wp-includes/pluggable.php

function cache_users( $user_ids ) {
		global $wpdb;

		$clean = _get_non_cached_ids( $user_ids, 'users' );

		if ( empty( $clean ) ) {
			return;
		}

		$list = implode( ',', $clean );

		$users = $wpdb->get_results( "SELECT * FROM $wpdb->users WHERE ID IN ($list)" );

		$ids = array();
		foreach ( $users as $user ) {
			update_user_caches( $user );
			$ids[] = $user->ID;
		}
		update_meta_cache( 'user', $ids );
	}

Changelog

Version Description
3.0.0 Introduced.

© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/cache_users