wp_cache_set_last_changed

函数
wp_cache_set_last_changed ( $group )
参数
  • (string) $group Where the cache contents are grouped.
    Required:
返回值
  • (string) UNIX timestamp when the group was last changed.
定义位置
相关方法
wp_cache_get_last_changedwp_cache_set_users_last_changedwp_cache_set_terms_last_changedwp_cache_set_sites_last_changedwp_cache_set_posts_last_changed
引入
6.3.0
弃用
-

将指定缓存组的上次更改日期设置为现在。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_cache_set_last_changed( $group ) {
$previous_time = wp_cache_get( 'last_changed', $group );
$time = microtime();
wp_cache_set( 'last_changed', $time, $group );
/**
* Fires after a cache group `last_changed` time is updated.
* This may occur multiple times per page load and registered
* actions must be performant.
*
* @since 6.3.0
*
* @param string $group The cache group name.
* @param int $time The new last changed time.
* @param int|false $previous_time The previous last changed time. False if not previously set.
*/
do_action( 'wp_cache_set_last_changed', $group, $time, $previous_time );
return $time;
}
function wp_cache_set_last_changed( $group ) { $previous_time = wp_cache_get( 'last_changed', $group ); $time = microtime(); wp_cache_set( 'last_changed', $time, $group ); /** * Fires after a cache group `last_changed` time is updated. * This may occur multiple times per page load and registered * actions must be performant. * * @since 6.3.0 * * @param string $group The cache group name. * @param int $time The new last changed time. * @param int|false $previous_time The previous last changed time. False if not previously set. */ do_action( 'wp_cache_set_last_changed', $group, $time, $previous_time ); return $time; }
function wp_cache_set_last_changed( $group ) {
	$previous_time = wp_cache_get( 'last_changed', $group );

	$time = microtime();

	wp_cache_set( 'last_changed', $time, $group );

	/**
	 * Fires after a cache group `last_changed` time is updated.
	 * This may occur multiple times per page load and registered
	 * actions must be performant.
	 *
	 * @since 6.3.0
	 *
	 * @param string    $group         The cache group name.
	 * @param int       $time          The new last changed time.
	 * @param int|false $previous_time The previous last changed time. False if not previously set.
	 */
	do_action( 'wp_cache_set_last_changed', $group, $time, $previous_time );

	return $time;
}

常见问题

FAQs
查看更多 >