_prime_network_caches()WP 4.6.0

Adds any networks from the given IDs to the cache that do not already exist in cache.

Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.

No Hooks.


null. Nothing (null).


_prime_network_caches( $network_ids );
$network_ids(array) (required)
Array of network IDs.



Since 4.6.0 Introduced.
Since 6.1.0 This function is no longer marked as "private".

_prime_network_caches() code WP 6.5.4

function _prime_network_caches( $network_ids ) {
	global $wpdb;

	$non_cached_ids = _get_non_cached_ids( $network_ids, 'networks' );
	if ( ! empty( $non_cached_ids ) ) {
		$fresh_networks = $wpdb->get_results( sprintf( "SELECT $wpdb->site.* FROM $wpdb->site WHERE id IN (%s)", implode( ',', array_map( 'intval', $non_cached_ids ) ) ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared

		update_network_cache( $fresh_networks );