Make WordPress Core

Changeset 27142


Ignore:
Timestamp:
02/09/2014 05:41:07 PM (10 years ago)
Author:
wonderboymusic
Message:

Reuse the terms cache group for taxonomy cache invalidation.

See #22526, #14485, [27101], [27102].

Location:
trunk
Files:
2 edited

Legend:

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

    r27141 r27142  
    35173517 */
    35183518function get_taxonomy_last_changed( $taxonomy ) {
    3519     $last_changed = wp_cache_get( 'last_changed', $taxonomy );
     3519    $key = $taxonomy . '_last_changed';
     3520    $last_changed = wp_cache_get( $key, 'terms' );
    35203521    if ( ! $last_changed ) {
    35213522        $last_changed = microtime();
    3522         wp_cache_set( 'last_changed', $last_changed, $taxonomy );
     3523        wp_cache_set( $key, $last_changed, 'terms' );
    35233524    }
    35243525    return $last_changed;
     
    35343535 */
    35353536function set_taxonomy_last_changed( $taxonomy ) {
    3536     wp_cache_delete( 'last_changed', $taxonomy );
     3537    wp_cache_delete( $taxonomy . '_last_changed', 'terms' );
    35373538    return get_taxonomy_last_changed( $taxonomy );
    35383539}
     
    35543555function post_taxonomy_is_fresh( $id, $taxonomy ) {
    35553556    $last_changed = get_taxonomy_last_changed( $taxonomy );
    3556     $post_last_changed = wp_cache_get( $id, $taxonomy . '_last_changed' );
     3557    $key = $id . '_' . $taxonomy . '_last_changed';
     3558    $post_last_changed = wp_cache_get( $key, 'terms' );
    35573559    if ( ! $post_last_changed || $last_changed !== $post_last_changed ) {
    3558         wp_cache_set( $id, $last_changed, $taxonomy . '_last_changed' );
     3560        wp_cache_set( $key, $last_changed, 'terms' );
    35593561        return false;
    35603562    }
     
    35783580function taxonomy_hierarchy_is_fresh( $taxonomy ) {
    35793581    $last_changed = get_taxonomy_last_changed( $taxonomy );
    3580     $hierarchy_last_changed = wp_cache_get( 'hierarchy_last_changed', $taxonomy );
     3582    $key = $taxonomy . '_hierarchy_last_changed';
     3583    $hierarchy_last_changed = wp_cache_get( $key, 'terms' );
    35813584    if ( ! $hierarchy_last_changed || $last_changed !== $hierarchy_last_changed ) {
    3582         wp_cache_set( 'hierarchy_last_changed', $last_changed, $taxonomy );
     3585        wp_cache_set( $key, $last_changed, 'terms' );
    35833586        return false;
    35843587    }
  • trunk/tests/phpunit/tests/term/cache.php

    r27104 r27142  
    3535    function test_get_taxonomy_last_changed() {
    3636        $last_changed = get_taxonomy_last_changed( 'category' );
    37         $last_changed_cache = wp_cache_get( 'last_changed', 'category' );
     37        $key = 'category_last_changed';
     38        $last_changed_cache = wp_cache_get( $key, 'terms' );
    3839        $this->assertEquals( $last_changed, $last_changed_cache );
    39         wp_cache_delete( 'last_changed', 'category' );
     40        wp_cache_delete( $key, 'terms' );
    4041        $this->assertEquals( $last_changed, $last_changed_cache );
    4142        $last_changed = get_taxonomy_last_changed( 'category' );
Note: See TracChangeset for help on using the changeset viewer.