Make WordPress Core


Ignore:
Timestamp:
10/16/2014 04:44:13 AM (11 years ago)
Author:
wonderboymusic
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/functions.php

    r29833 r29915  
    46304630    return (bool) $var;
    46314631}
     4632
     4633/**
     4634 * Helper function to retrieve an incrementer identified by $group
     4635 *
     4636 * @since 4.1.0
     4637 *
     4638 * @param string $group The cache group for the incrementer.
     4639 * @param bool $force Whether or not to generate a new incrementor.
     4640 * @return int The timestamp representing 'last_changed'.
     4641 */
     4642function wp_get_last_changed( $group, $force = false ) {
     4643    $last_changed = wp_cache_get( 'last_changed', $group );
     4644    if ( ! $last_changed || true === $force ) {
     4645        $last_changed = microtime();
     4646        wp_cache_set( 'last_changed', $last_changed, $group );
     4647    }
     4648    return $last_changed;
     4649}
Note: See TracChangeset for help on using the changeset viewer.