1. 首页
  2. WordPress 函数手册

wp_cache_get()

wp_cache_get( int|string $key, string $group = , bool $force = false, bool $found = null )

按键和组从缓存中检索缓存内容。
Retrieves the cache contents from the cache by key and group.

目录锚点:#说明#参数#源码


说明(Description)

另请参阅WP_Object_Cache::get()


参数(Parameters)

参数 类型 说明
$key (int | string) 存储缓存内容的键。
$group (string) 缓存内容分组的位置。
$force (bool) 是否强制从永久缓存更新本地缓存。
$found (bool) 是否在缓存中找到该键(通过引用传递)。消除返回false(可存储值)的歧义。

源码(Source)

/**
 * Retrieves the cache contents from the cache by key and group.
 *
 * @since 2.0.0
 *
 * @global WP_Object_Cache $wp_object_cache
 *
 * @param int|string $key What the contents in the cache are called
 * @param string $group Where the cache contents are grouped
 * @param bool $force Whether to force an update of the local cache from the persistent cache (default is false)
 * @param bool &$found Whether key was found in the cache. Disambiguates a return of false, a storable value.
 * @return bool|mixed False on failure to retrieve contents or the cache
 *		              contents on success
 */
function wp_cache_get( $key, $group = '', $force = false, &$found = null ) {
	global $wp_object_cache;

	return $wp_object_cache->get( $key, $group, $force, $found );
}
更新版本 源码位置 使用 被使用
2.0.0 wp-includes/cache.php 2 2

wp_cache_get() 为WP2原创文章,链接:https://www.wp2.cn/functions/wp_cache_get/