wp_cache_set()添加一个数据到缓存中

目录

描述

Saves the data to the cache.

wp_cache_set() 描述

用法

<?php wp_cache_set$key$data$group$expire ); ?>

wp_cache_set() 用法

参数

$key

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

默认值: None

$data

(mixed) (必填) The value you want to store.

默认值: None

$group

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

默认值: None

$expire

(integer) (可选) Defines how many seconds to keep the cache for. Defaults to 0 (as long as possible).

默认值: 0

wp_cache_set() 参数

历史

添加于 版本: 2.5.0

wp_cache_set() 历史

源文件

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

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
/**
 * Saves the data to the cache.
 *
 * @since 2.0.0
 *
 * @global WP_Object_Cache $wp_object_cache
 *
 * @param int|string $key What to call the contents in the cache
 * @param mixed $data The contents to store in the cache
 * @param string $group Where to group the cache contents
 * @param int $expire When to expire the cache contents
 * @return bool False on failure, true on success
 */
function wp_cache_set( $key, $data, $group = '', $expire = 0 ) {
	global $wp_object_cache;

	return $wp_object_cache->set( $key, $data, $group, (int) $expire );
}

wp_cache_set() 源文件

相关