mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-04 04:34:31 +00:00
Cache get_term_by() calls:
* Add a helper function, `wp_get_last_changed()`, to retrieve a last-modified timestamp by cache group
* When caching a term, also make cache entries for slug and name via `slug:{$term_id}` and `name:{$term_id}` keys in the `$taxonomy:$last_changed` bucket that reference the term_id
* In `clean_term_cache()` and `update_term_cache()`, respect `$_wp_suspend_cache_invalidation`
* Original term cache entries maintain BC
Adds unit tests.
Props wonderboymusic, tollmanz, boonebgorges.
Fixes #21760.
git-svn-id: https://develop.svn.wordpress.org/trunk@29915 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -4629,3 +4629,21 @@ function wp_validate_boolean( $var ) {
|
||||
|
||||
return (bool) $var;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to retrieve an incrementer identified by $group
|
||||
*
|
||||
* @since 4.1.0
|
||||
*
|
||||
* @param string $group The cache group for the incrementer.
|
||||
* @param bool $force Whether or not to generate a new incrementor.
|
||||
* @return int The timestamp representing 'last_changed'.
|
||||
*/
|
||||
function wp_get_last_changed( $group, $force = false ) {
|
||||
$last_changed = wp_cache_get( 'last_changed', $group );
|
||||
if ( ! $last_changed || true === $force ) {
|
||||
$last_changed = microtime();
|
||||
wp_cache_set( 'last_changed', $last_changed, $group );
|
||||
}
|
||||
return $last_changed;
|
||||
}
|
||||
Reference in New Issue
Block a user