update_meta_cache example

if ( null !== $check ) {
        if ( $single && is_array( $check ) ) {
            return $check[0];
        } else {
            return $check;
        }
    }

    $meta_cache = wp_cache_get( $object_id$meta_type . '_meta' );

    if ( ! $meta_cache ) {
        $meta_cache = update_meta_cache( $meta_type, array( $object_id ) );
        if ( isset( $meta_cache[ $object_id ] ) ) {
            $meta_cache = $meta_cache[ $object_id ];
        } else {
            $meta_cache = null;
        }
    }

    if ( ! $meta_key ) {
        return $meta_cache;
    }

    

    public function lazyload_meta_callback( $check$object_id$meta_key$single$meta_type ) {
        if ( empty( $this->pending_objects[ $meta_type ] ) ) {
            return $check;
        }

        $object_ids = array_keys( $this->pending_objects[ $meta_type ] );
        if ( $object_id && ! in_array( $object_id$object_ids, true ) ) {
            $object_ids[] = $object_id;
        }

        update_meta_cache( $meta_type$object_ids );

        // No need to run again for this set of objects.         $this->reset_queue( $meta_type );

        return $check;
    }
}

function update_postmeta_cache( $post_ids ) {
    return update_meta_cache( 'post', $post_ids );
}

/** * Will clean the attachment in the cache. * * Cleaning means delete from the cache. Optionally will clean the term * object cache associated with the attachment ID. * * This function will not run if $_wp_suspend_cache_invalidation is not empty. * * @since 3.0.0 * * @global bool $_wp_suspend_cache_invalidation * * @param int $id The attachment ID in the cache to clean. * @param bool $clean_terms Optional. Whether to clean terms cache. Default false. */

function update_termmeta_cache( $term_ids ) {
    return update_meta_cache( 'term', $term_ids );
}


/** * Queue term meta for lazy-loading. * * @since 6.3.0 * * @param array $term_ids List of term IDs. */
function wp_lazyload_term_meta( array $term_ids ) {
    
foreach ( (array) $comments as $comment ) {
        $data[ $comment->comment_ID ] = $comment;
    }
    wp_cache_add_multiple( $data, 'comment' );

    if ( $update_meta_cache ) {
        // Avoid `wp_list_pluck()` in case `$comments` is passed by reference.         $comment_ids = array();
        foreach ( $comments as $comment ) {
            $comment_ids[] = $comment->comment_ID;
        }
        update_meta_cache( 'comment', $comment_ids );
    }
}

/** * Adds any comments from the given IDs to the cache that do not already exist in cache. * * @since 4.4.0 * @since 6.1.0 This function is no longer marked as "private". * @since 6.3.0 Use wp_lazyload_comment_meta() for lazy-loading of comment meta. * * @see update_comment_cache() * @global wpdb $wpdb WordPress database abstraction object. * * @param int[] $comment_ids Array of comment IDs. * @param bool $update_meta_cache Optional. Whether to update the meta cache. Default true. */

    function cache_users( $user_ids ) {
        global $wpdb;

        update_meta_cache( 'user', $user_ids );

        $clean = _get_non_cached_ids( $user_ids, 'users' );

        if ( empty( $clean ) ) {
            return;
        }

        $list = implode( ',', $clean );

        $users = $wpdb->get_results( "SELECT * FROM $wpdb->users WHERE ID IN ($list)" );

        

function get_user_metavalues($ids) {
    _deprecated_function( __FUNCTION__, '3.3.0' );

    $objects = array();

    $ids = array_map('intval', $ids);
    foreach ( $ids as $id )
        $objects[$id] = array();

    $metas = update_meta_cache('user', $ids);

    foreach ( $metas as $id => $meta ) {
        foreach ( $meta as $key => $metavalues ) {
            foreach ( $metavalues as $value ) {
                $objects[$id][] = (object)array( 'user_id' => $id, 'meta_key' => $key, 'meta_value' => $value);
            }
        }
    }

    return $objects;
}


function update_sitemeta_cache( $site_ids ) {
    // Ensure this filter is hooked in even if the function is called early.     if ( ! has_filter( 'update_blog_metadata_cache', 'wp_check_site_meta_support_prefilter' ) ) {
        add_filter( 'update_blog_metadata_cache', 'wp_check_site_meta_support_prefilter' );
    }
    return update_meta_cache( 'blog', $site_ids );
}

/** * Retrieves a list of sites matching requested arguments. * * @since 4.6.0 * @since 4.8.0 Introduced the 'lang_id', 'lang__in', and 'lang__not_in' parameters. * * @see WP_Site_Query::parse_query() * * @param string|array $args Optional. Array or string of arguments. See WP_Site_Query::__construct() * for information on accepted arguments. Default empty array. * @return array|int List of WP_Site objects, a list of site IDs when 'fields' is set to 'ids', * or the number of sites when 'count' is passed as a query var. */
Home | Imprint | This part of the site doesn't use cookies.