_prime_site_caches()WP 4.6.0

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

Внутренняя функция — эта функция рассчитана на использование самим ядром. Не рекомендуется использовать эту функцию в своем коде.

Хуков нет.

Возвращает

null. Ничего (null).

Использование

_prime_site_caches( $ids, $update_meta_cache );
$ids(массив) (обязательный)
ID list.
$update_meta_cache(true|false)
Whether to update the meta cache.
По умолчанию: true

Заметки

  • Смотрите: update_site_cache()
  • Global. wpdb. $wpdb WordPress database abstraction object.

Список изменений

С версии 4.6.0 Введена.
С версии 5.1.0 Introduced the $update_meta_cache parameter.
С версии 6.1.0 This function is no longer marked as "private".
С версии 6.3.0 Use wp_lazyload_site_meta() for lazy-loading of site meta.

Код _prime_site_caches() WP 6.5.2

function _prime_site_caches( $ids, $update_meta_cache = true ) {
	global $wpdb;

	$non_cached_ids = _get_non_cached_ids( $ids, 'sites' );
	if ( ! empty( $non_cached_ids ) ) {
		$fresh_sites = $wpdb->get_results( sprintf( "SELECT * FROM $wpdb->blogs WHERE blog_id IN (%s)", implode( ',', array_map( 'intval', $non_cached_ids ) ) ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared

		update_site_cache( $fresh_sites, false );
	}

	if ( $update_meta_cache ) {
		wp_lazyload_site_meta( $ids );
	}
}