返回介绍

clean_post_cache()

发布于 2017-09-10 21:43:14 字数 3415 浏览 1269 评论 0 收藏 0

clean_post_cache( int|WP_Post $post )

Will clean the post in the cache.


description

Cleaning means delete from the cache of the post. Will call to clean the term object cache associated with the post ID.

This function not run if $_wp_suspend_cache_invalidation is not empty. See wp_suspend_cache_invalidation().


参数

$post

(int|WP_Post) (Required) Post ID or post object to remove from the cache.


源代码

File: wp-includes/post.php

function clean_post_cache( $post ) {
	global $_wp_suspend_cache_invalidation;

	if ( ! empty( $_wp_suspend_cache_invalidation ) )
		return;

	$post = get_post( $post );
	if ( empty( $post ) )
		return;

	wp_cache_delete( $post->ID, 'posts' );
	wp_cache_delete( $post->ID, 'post_meta' );

	clean_object_term_cache( $post->ID, $post->post_type );

	wp_cache_delete( 'wp_get_archives', 'general' );

	/**
	 * Fires immediately after the given post's cache is cleaned.
	 *
	 * @since 2.5.0
	 *
	 * @param int     $post_id Post ID.
	 * @param WP_Post $post    Post object.
	 */
	do_action( 'clean_post_cache', $post->ID, $post );

	if ( 'page' == $post->post_type ) {
		wp_cache_delete( 'all_page_ids', 'posts' );

		/**
		 * Fires immediately after the given page's cache is cleaned.
		 *
		 * @since 2.5.0
		 *
		 * @param int $post_id Post ID.
		 */
		do_action( 'clean_page_cache', $post->ID );
	}

	wp_cache_set( 'last_changed', microtime(), 'posts' );
}

更新日志

Versiondescription
2.0.0Introduced.

相关函数

Uses

  • wp-includes/cache.php: wp_cache_delete()
  • wp-includes/cache.php: wp_cache_set()
  • wp-includes/taxonomy.php: clean_object_term_cache()
  • wp-includes/plugin.php: do_action()
  • wp-includes/post.php: clean_post_cache
  • wp-includes/post.php: clean_page_cache
  • wp-includes/post.php: get_post()
  • Show 2 more uses Hide more uses

Used By

  • wp-includes/theme.php: _wp_keep_alive_customize_changeset_dependent_auto_drafts()
  • wp-includes/theme.php: _wp_customize_publish_changeset()
  • wp-includes/post.php: wp_add_trashed_suffix_to_post_name_for_post()
  • wp-admin/includes/user.php: wp_delete_user()
  • wp-admin/includes/class-wp-posts-list-table.php: WP_Posts_List_Table::_display_rows_hierarchical()
  • wp-includes/deprecated.php: clean_page_cache()
  • wp-includes/post.php: wp_delete_attachment()
  • wp-includes/post.php: wp_publish_post()
  • wp-includes/post.php: add_ping()
  • wp-includes/post.php: wp_insert_post()
  • wp-includes/post.php: wp_delete_post()
  • wp-includes/post.php: set_post_type()
  • wp-includes/comment.php: wp_update_comment_count_now()
  • Show 8 more used by Hide more used by

User Contributed Notes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文