Make WordPress Core

Ticket #22024: 22024.2.diff

File 22024.2.diff, 1.2 KB (added by ryan, 12 years ago)

Use wp_cache_incr()

  • wp-includes/comment.php

     
    249249
    250250                // $args can be whatever, only use the args defined in defaults to compute the key
    251251                $key = md5( serialize( compact(array_keys($defaults)) )  );
    252                 $last_changed = wp_cache_get('last_changed', 'comment');
    253                 if ( ! $last_changed ) {
    254                         $last_changed = time();
    255                         wp_cache_set('last_changed', $last_changed, 'comment');
    256                 }
     252                $last_changed = wp_cache_get( 'last_changed', 'comment' );
     253                if ( ! $last_changed )
     254                        $last_changed = wp_cache_incr( 'last_changed', 1, 'comment' );
    257255                $cache_key = "get_comments:$key:$last_changed";
    258256
    259257                if ( $cache = wp_cache_get( $cache_key, 'comment' ) ) {
     
    12931291        $comment = get_comment($id);
    12941292        do_action('wp_insert_comment', $id, $comment);
    12951293
     1294        wp_cache_incr('last_changed', 1, 'comment');
     1295
    12961296        return $id;
    12971297}
    12981298
     
    19641964        foreach ( (array) $ids as $id )
    19651965                wp_cache_delete($id, 'comment');
    19661966
    1967         wp_cache_set('last_changed', time(), 'comment');
     1967        wp_cache_incr('last_changed', 1, 'comment');
    19681968}
    19691969
    19701970/**