wp_prime_site_option_caches()
云策文档标注
概述
wp_prime_site_option_caches() 函数用于通过单次数据库查询,将当前网络的特定网络选项预加载到缓存中,以提高性能。它仅加载缓存中不存在的选项,并在非多站点环境中回退到 wp_prime_option_caches()。
关键要点
- 函数作用:预加载网络选项到缓存,减少数据库查询次数
- 参数:$options(必需),字符串数组,指定要加载的选项名称
- 内部实现:调用 wp_prime_network_option_caches(null, $options)
- 适用场景:多站点环境,非多站点时自动调用 wp_prime_option_caches()
- 相关函数:wp_prime_network_option_caches()、wp_salt()、set_site_transient()、get_site_transient()
- 版本引入:WordPress 6.6.0
代码示例
function wp_prime_site_option_caches( array $options ) {
wp_prime_network_option_caches( null, $options );
}
原文内容
Primes specific network options for the current network into the cache with a single database query.
Description
Only network options that do not already exist in cache will be loaded.
If site is not multisite, then call wp_prime_option_caches() .
See also
Parameters
$optionsstring[]required-
An array of option names to be loaded.
Source
function wp_prime_site_option_caches( array $options ) {
wp_prime_network_option_caches( null, $options );
}
Changelog
| Version | Description |
|---|---|
| 6.6.0 | Introduced. |