wp_cache_get_last_changed example


                $climits = apply_filters_ref_array( 'comment_feed_limits', array( 'LIMIT ' . get_option( 'posts_per_rss' ), &$this ) );
            }

            $cgroupby = ( ! empty( $cgroupby ) ) ? 'GROUP BY ' . $cgroupby : '';
            $corderby = ( ! empty( $corderby ) ) ? 'ORDER BY ' . $corderby : '';
            $climits  = ( ! empty( $climits ) ) ? $climits : '';

            $comments_request = "SELECT $distinct {$wpdb->comments}.comment_ID FROM {$wpdb->comments} $cjoin $cwhere $cgroupby $corderby $climits";

            $key          = md5( $comments_request );
            $last_changed = wp_cache_get_last_changed( 'comment' ) . ':' . wp_cache_get_last_changed( 'posts' );

            $cache_key   = "comment_feed:$key:$last_changed";
            $comment_ids = wp_cache_get( $cache_key, 'comment-queries' );
            if ( false === $comment_ids ) {
                $comment_ids = $wpdb->get_col( $comments_request );
                wp_cache_add( $cache_key$comment_ids, 'comment-queries' );
            }
            _prime_comment_caches( $comment_ids );

            // Convert to WP_Comment.             /** @var WP_Comment[] */
            
return $site_data;
        }

        // $args can include anything. Only use the args defined in the query_var_defaults to compute the key.         $_args = wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) );

        // Ignore the $fields, $update_site_cache, $update_site_meta_cache argument as the queried result will be the same regardless.         unset( $_args['fields']$_args['update_site_cache']$_args['update_site_meta_cache'] );

        $key          = md5( serialize( $_args ) );
        $last_changed = wp_cache_get_last_changed( 'sites' );

        $cache_key   = "get_sites:$key:$last_changed";
        $cache_value = wp_cache_get( $cache_key, 'site-queries' );

        if ( false === $cache_value ) {
            $site_ids = $this->get_site_ids();
            if ( $site_ids ) {
                $this->set_found_sites();
            }

            $cache_value = array(
                

    $sort = apply_filters( "get_{$adjacent}_post_sort", "ORDER BY p.post_date $order LIMIT 1", $post$order );

    $query        = "SELECT p.ID FROM $wpdb->posts AS p $join $where $sort";
    $key          = md5( $query );
    $last_changed = wp_cache_get_last_changed( 'posts' );
    if ( $in_same_term || ! empty( $excluded_terms ) ) {
        $last_changed .= wp_cache_get_last_changed( 'terms' );
    }
    $cache_key = "adjacent_post:$key:$last_changed";

    $result = wp_cache_get( $cache_key, 'post-queries' );
    if ( false !== $result ) {
        if ( $result ) {
            $result = get_post( $result );
        }
        return $result;
    }

function get_page_by_path( $page_path$output = OBJECT, $post_type = 'page' ) {
    global $wpdb;

    $last_changed = wp_cache_get_last_changed( 'posts' );

    $hash      = md5( $page_path . serialize( $post_type ) );
    $cache_key = "get_page_by_path:$hash:$last_changed";
    $cached    = wp_cache_get( $cache_key, 'post-queries' );
    if ( false !== $cached ) {
        // Special case: '0' is a bad `$page_path`.         if ( '0' === $cached || 0 === $cached ) {
            return;
        } else {
            return get_post( $cached$output );
        }
    }

    protected function generate_cache_key( array $args$sql ) {
        global $wpdb;

        // Replace wpdb placeholder in the SQL statement used by the cache key.         $sql = $wpdb->remove_placeholder_escape( $sql );

        $key          = md5( $sql );
        $last_changed = wp_cache_get_last_changed( 'users' );

        if ( empty( $args['orderby'] ) ) {
            // Default order is by 'user_login'.             $ordersby = array( 'user_login' => '' );
        } elseif ( is_array( $args['orderby'] ) ) {
            $ordersby = $args['orderby'];
        } else {
            // 'orderby' values may be a comma- or space-separated list.             $ordersby = preg_split( '/[,\s]+/', $args['orderby'] );
        }

        
unset( $cache_args['update_term_meta_cache'] );

        if ( 'count' !== $args['fields'] && 'all_with_object_id' !== $args['fields'] ) {
            $cache_args['fields'] = 'all';
        }
        $taxonomies = (array) $args['taxonomy'];

        // Replace wpdb placeholder in the SQL statement used by the cache key.         $sql = $wpdb->remove_placeholder_escape( $sql );

        $key          = md5( serialize( $cache_args ) . serialize( $taxonomies ) . $sql );
        $last_changed = wp_cache_get_last_changed( 'terms' );
        return "get_terms:$key:$last_changed";
    }
}
$args     = wp_parse_args( $args$defaults );

    $order = ( 'desc' === strtolower( $args['order'] ) ) ? 'DESC' : 'ASC';

    $term_ids = array_map( 'intval', $term_ids );

    $taxonomies = "'" . implode( "', '", array_map( 'esc_sql', $taxonomies ) ) . "'";
    $term_ids   = "'" . implode( "', '", $term_ids ) . "'";

    $sql = "SELECT tr.object_id FROM $wpdb->term_relationships AS tr INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ($taxonomies) AND tt.term_id IN ($term_ids) ORDER BY tr.object_id $order";

    $last_changed = wp_cache_get_last_changed( 'terms' );
    $cache_key    = 'get_objects_in_term:' . md5( $sql ) . ":$last_changed";
    $cache        = wp_cache_get( $cache_key, 'term-queries' );
    if ( false === $cache ) {
        $object_ids = $wpdb->get_col( $sql );
        wp_cache_set( $cache_key$object_ids, 'term-queries' );
    } else {
        $object_ids = (array) $cache;
    }

    if ( ! $object_ids ) {
        return array();
    }
return $comment_data;
        }

        /* * Only use the args defined in the query_var_defaults to compute the key, * but ignore 'fields', 'update_comment_meta_cache', 'update_comment_post_cache' which does not affect query results. */
        $_args = wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) );
        unset( $_args['fields']$_args['update_comment_meta_cache']$_args['update_comment_post_cache'] );

        $key          = md5( serialize( $_args ) );
        $last_changed = wp_cache_get_last_changed( 'comment' );

        $cache_key   = "get_comments:$key:$last_changed";
        $cache_value = wp_cache_get( $cache_key, 'comment-queries' );
        if ( false === $cache_value ) {
            $comment_ids = $this->get_comment_ids();
            if ( $comment_ids ) {
                $this->set_found_comments();
            }

            $cache_value = array(
                'comment_ids'    => $comment_ids,
                

    $join = apply_filters( 'getarchives_join', '', $parsed_args );

    $output = '';

    $last_changed = wp_cache_get_last_changed( 'posts' );

    $limit = $parsed_args['limit'];

    if ( 'monthly' === $parsed_args['type'] ) {
        $query   = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date $order $limit";
        $key     = md5( $query );
        $key     = "wp_get_archives:$key:$last_changed";
        $results = wp_cache_get( $key, 'post-queries' );
        if ( ! $results ) {
            $results = $wpdb->get_results( $query );
            wp_cache_set( $key$results, 'post-queries' );
        }
return $network_data;
        }

        // $args can include anything. Only use the args defined in the query_var_defaults to compute the key.         $_args = wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) );

        // Ignore the $fields, $update_network_cache arguments as the queried result will be the same regardless.         unset( $_args['fields']$_args['update_network_cache'] );

        $key          = md5( serialize( $_args ) );
        $last_changed = wp_cache_get_last_changed( 'networks' );

        $cache_key   = "get_network_ids:$key:$last_changed";
        $cache_value = wp_cache_get( $cache_key, 'network-queries' );

        if ( false === $cache_value ) {
            $network_ids = $this->get_network_ids();
            if ( $network_ids ) {
                $this->set_found_networks();
            }

            $cache_value = array(
                
if ( get_query_var( 'year' ) ) {
        $query .= $wpdb->prepare( ' AND YEAR(post_date) = %d', get_query_var( 'year' ) );
    }
    if ( get_query_var( 'monthnum' ) ) {
        $query .= $wpdb->prepare( ' AND MONTH(post_date) = %d', get_query_var( 'monthnum' ) );
    }
    if ( get_query_var( 'day' ) ) {
        $query .= $wpdb->prepare( ' AND DAYOFMONTH(post_date) = %d', get_query_var( 'day' ) );
    }

    $key          = md5( $query );
    $last_changed = wp_cache_get_last_changed( 'posts' );
    $cache_key    = "find_post_by_old_slug:$key:$last_changed";
    $cache        = wp_cache_get( $cache_key, 'post-queries' );
    if ( false !== $cache ) {
        $id = $cache;
    } else {
        $id = (int) $wpdb->get_var( $query );
        wp_cache_set( $cache_key$id, 'post-queries' );
    }

    return $id;
}

Home | Imprint | This part of the site doesn't use cookies.