wp_cache_get()获取一个缓存变量

目录

描述

Retrieves the cache contents from the cache by key and group.

wp_cache_get() 描述

用法

<?php wp_cache_get$key$group$force$found ); ?>

wp_cache_get() 用法

参数

$key

(int/string) (必填) the key to indicate the value.

默认值: None

$group

(string) (可选) this is a way of grouping data within the cache. Allows you to use the same key across different groups.

默认值: None

$force

(boolean) (可选) Whether to force an update of the local cache from the persistent cache (default is false)

默认值: false

$found

(&boolean) (可选) Whether key was found in the cache. Disambiguates a return of false, a storable value

默认值: None

wp_cache_get() 参数

历史

添加于 版本: 2.0.0

wp_cache_get() 历史

源文件

wp_cache_get() 函数的代码位于 wp-includes/cache.php.

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
/**
 * 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 );
}

wp_cache_get() 源文件

相关