clean_blog_cache()
最后更新于:2021-11-25 20:32:01
clean_blog_cache( GC_Site|int$blog)Clean the blog cache
参数
- $blog
-
(GC_Site|int) (Required) The site object or ID to be cleared from cache.
源文件
文件: gc-includes/ms-site.php
function clean_blog_cache( $blog ) {
global $_gc_suspend_cache_invalidation;
if ( ! empty( $_gc_suspend_cache_invalidation ) ) {
return;
}
if ( empty( $blog ) ) {
return;
}
$blog_id = $blog;
$blog = get_site( $blog_id );
if ( ! $blog ) {
if ( ! is_numeric( $blog_id ) ) {
return;
}
// Make sure a GC_Site object exists even when the site has been deleted.
$blog = new GC_Site(
(object) array(
'blog_id' => $blog_id,
'domain' => null,
'path' => null,
)
);
}
$blog_id = $blog->blog_id;
$domain_path_key = md5( $blog->domain . $blog->path );
gc_cache_delete( $blog_id, 'sites' );
gc_cache_delete( $blog_id, 'site-details' );
gc_cache_delete( $blog_id, 'blog-details' );
gc_cache_delete( $blog_id . 'short', 'blog-details' );
gc_cache_delete( $domain_path_key, 'blog-lookup' );
gc_cache_delete( $domain_path_key, 'blog-id-cache' );
gc_cache_delete( $blog_id, 'blog_meta' );
/**
* Fires immediately after a site has been removed from the object cache.
*
* @since 4.6.0
*
* @param int $id Blog ID.
* @param GC_Site $blog Site object.
* @param string $domain_path_key md5 hash of domain and path.
*/
do_action( 'clean_site_cache', $blog_id, $blog, $domain_path_key );
gc_cache_set( 'last_changed', microtime(), 'sites' );
/**
* Fires after the blog details cache is cleared.
*
* @since 3.4.0
* @deprecated 4.9.0 Use {@see 'clean_site_cache'} instead.
*
* @param int $blog_id Blog ID.
*/
do_action_deprecated( 'refresh_blog_details', array( $blog_id ), '4.9.0', 'clean_site_cache' );
}