wp_cache_add() - WordPress 函数参考中文文档

返回介绍

wp_cache_add()

发布于 2017-09-11 字数3787 浏览 934 评论 0

wp_cache_add( int|string $key,  mixed $data,  string $group = '',  int $expire )

Adds data to the cache, if the cache key doesn’t already exist.


描述


参数

$key

(int|string)
(Required)
The cache key to use for retrieval later.

$data

(mixed)
(Required)
The data to add to the cache.

$group

(string)
(Optional)
The group to add the cache to. Enables the same key to be used across groups.

Default value: ”

$expire

(int)
(Optional)
When the cache data should expire, in seconds. Default 0 (no expiration).


返回值

(bool) False if cache key and group already exist, true on success.


源代码

File: wp-includes/cache.php

function wp_cache_add( $key, $data, $group = '', $expire = 0 ) {
	global $wp_object_cache;

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

更新日志

Version 描述
2.0.0 Introduced.

相关函数

Uses

  • wp-includes/cache.php:
    WP_Object_Cache::add()

Used By

  • wp-includes/class-wp-term-query.php:
    WP_Term_Query::get_terms()
  • wp-includes/class-wp-network-query.php:
    WP_Network_Query::get_networks()
  • wp-includes/ms-blogs.php:
    update_network_cache()
  • wp-includes/ms-blogs.php:
    update_site_cache()
  • wp-includes/ms-load.php:
    ms_load_current_site_and_network()
  • wp-includes/class-wp-site-query.php:
    WP_Site_Query::get_sites()
  • wp-includes/class-wp-site.php:
    WP_Site::get_instance()
  • wp-includes/class-wp-network.php:
    WP_Network::get_instance()
  • wp-includes/class-wp-network.php:
    WP_Network::get_by_path()
  • wp-includes/class-wp-comment.php:
    WP_Comment::get_instance()
  • wp-includes/class-wp-term.php:
    WP_Term::get_instance()
  • wp-includes/class-wp-comment-query.php:
    WP_Comment_Query::get_comments()
  • wp-admin/includes/taxonomy.php:
    get_terms_to_edit()
  • wp-admin/includes/template.php:
    get_inline_data()
  • wp-includes/category-template.php:
    get_the_terms()
  • wp-includes/class-wp-theme.php:
    WP_Theme::cache_add()
  • wp-includes/deprecated.php:
    get_all_category_ids()
  • wp-includes/taxonomy.php:
    update_object_term_cache()
  • wp-includes/taxonomy.php:
    update_term_cache()
  • wp-includes/option.php:
    wp_load_alloptions()
  • wp-includes/option.php:
    get_option()
  • wp-includes/user.php:
    update_user_caches()
  • wp-includes/class-wp-post.php:
    WP_Post::get_instance()
  • wp-includes/post.php:
    wp_mime_type_icon()
  • wp-includes/post.php:
    update_post_cache()
  • wp-includes/post.php:
    get_all_page_ids()
  • wp-includes/bookmark.php:
    get_bookmark()
  • wp-includes/comment.php:
    update_comment_cache()
  • wp-includes/meta.php:
    update_meta_cache()
  • Show 24 more used by
    Hide more used by


User Contributed Notes

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!