当前位置: 首页>>代码示例>>PHP>>正文


PHP _get_non_cached_ids函数代码示例

本文整理汇总了PHP中_get_non_cached_ids函数的典型用法代码示例。如果您正苦于以下问题:PHP _get_non_cached_ids函数的具体用法?PHP _get_non_cached_ids怎么用?PHP _get_non_cached_ids使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了_get_non_cached_ids函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: cache_users

 /**
  * Retrieve info for user lists to prevent multiple queries by get_userdata()
  *
  * @since 3.0.0
  *
  * @param array $user_ids User ID numbers list
  */
 function cache_users($user_ids)
 {
     global $wpdb;
     $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})");
     $ids = array();
     foreach ($users as $user) {
         update_user_caches($user);
         $ids[] = $user->ID;
     }
     update_meta_cache('user', $ids);
 }
开发者ID:cybKIRA,项目名称:roverlink-updated,代码行数:23,代码来源:pluggable.php

示例2: _prime_post_caches

/**
 * Adds any posts from the given ids to the cache that do not already exist in cache
 *
 * @since 3.4.0
 * @access private
 *
 * @see update_post_caches()
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $ids               ID list.
 * @param bool  $update_term_cache Optional. Whether to update the term cache. Default true.
 * @param bool  $update_meta_cache Optional. Whether to update the meta cache. Default true.
 */
function _prime_post_caches($ids, $update_term_cache = true, $update_meta_cache = true)
{
    global $wpdb;
    $non_cached_ids = _get_non_cached_ids($ids, 'posts');
    if (!empty($non_cached_ids)) {
        $fresh_posts = $wpdb->get_results(sprintf("SELECT {$wpdb->posts}.* FROM {$wpdb->posts} WHERE ID IN (%s)", join(",", $non_cached_ids)));
        update_post_caches($fresh_posts, 'any', $update_term_cache, $update_meta_cache);
    }
}
开发者ID:SayenkoDesign,项目名称:ividf,代码行数:23,代码来源:post.php

示例3: _prime_comment_caches

/**
 * Adds any comments from the given IDs to the cache that do not already exist in cache.
 *
 * @since 4.4.0
 * @access private
 *
 * @see update_comment_cache()
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $comment_ids       Array of comment IDs.
 * @param bool  $update_meta_cache Optional. Whether to update the meta cache. Default true.
 */
function _prime_comment_caches($comment_ids, $update_meta_cache = true)
{
    global $wpdb;
    $non_cached_ids = _get_non_cached_ids($comment_ids, 'comment');
    if (!empty($non_cached_ids)) {
        $fresh_comments = $wpdb->get_results(sprintf("SELECT {$wpdb->comments}.* FROM {$wpdb->comments} WHERE comment_ID IN (%s)", join(",", array_map('intval', $non_cached_ids))));
        update_comment_cache($fresh_comments, $update_meta_cache);
    }
}
开发者ID:hadywisam,项目名称:WordPress,代码行数:21,代码来源:comment-functions.php

示例4: _prime_term_caches

/**
 * Adds any terms from the given IDs to the cache that do not already exist in cache.
 *
 * @since 4.6.0
 * @access private
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $term_ids          Array of term IDs.
 * @param bool  $update_meta_cache Optional. Whether to update the meta cache. Default true.
 */
function _prime_term_caches($term_ids, $update_meta_cache = true)
{
    global $wpdb;
    $non_cached_ids = _get_non_cached_ids($term_ids, 'terms');
    if (!empty($non_cached_ids)) {
        $fresh_terms = $wpdb->get_results(sprintf("SELECT t.*, tt.* FROM {$wpdb->terms} AS t INNER JOIN {$wpdb->term_taxonomy} AS tt ON t.term_id = tt.term_id WHERE t.term_id IN (%s)", join(",", array_map('intval', $non_cached_ids))));
        update_term_cache($fresh_terms, $update_meta_cache);
        if ($update_meta_cache) {
            update_termmeta_cache($non_cached_ids);
        }
    }
}
开发者ID:nicholasgriffintn,项目名称:WordPress,代码行数:23,代码来源:taxonomy.php

示例5: load_posts

 /**
  * Load all posts with one query, to prime the cache
  *
  * @see get_post()
  * @since 1.0.0
  *
  * @param array $all_post_ids List of Post IDs
  * @param bool $update_meta_cache Whether to update the Post Meta Cache (for table options and visibility)
  */
 public function load_posts(array $all_post_ids, $update_meta_cache = true)
 {
     global $wpdb;
     // Split post loading, to save memory
     $offset = 0;
     $length = 100;
     // 100 posts at a time
     $number_of_posts = count($all_post_ids);
     while ($offset < $number_of_posts) {
         $post_ids = array_slice($all_post_ids, $offset, $length);
         $post_ids = _get_non_cached_ids($post_ids, 'posts');
         // Don't load posts that are in the cache already
         if (!empty($post_ids)) {
             $post_ids_list = implode(',', $post_ids);
             $posts = $wpdb->get_results("SELECT {$wpdb->posts}.* FROM {$wpdb->posts} WHERE ID IN ({$post_ids_list})");
             update_post_cache($posts);
             if ($update_meta_cache) {
                 update_meta_cache('post', $post_ids);
                 // get all post meta data for all table posts, @see get_post_meta()
             }
         }
         $offset += $length;
         // next array_slice() $offset
     }
 }
开发者ID:heyjones,项目名称:crossfitpurpose,代码行数:34,代码来源:model-post.php

示例6: _prime_network_caches

/**
 * Adds any networks from the given IDs to the cache that do not already exist in cache.
 *
 * @since 4.6.0
 * @access private
 *
 * @see update_network_cache()
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $network_ids Array of network IDs.
 */
function _prime_network_caches($network_ids)
{
    global $wpdb;
    $non_cached_ids = _get_non_cached_ids($network_ids, 'networks');
    if (!empty($non_cached_ids)) {
        $fresh_networks = $wpdb->get_results(sprintf("SELECT {$wpdb->site}.* FROM {$wpdb->site} WHERE id IN (%s)", join(",", array_map('intval', $non_cached_ids))));
        update_network_cache($fresh_networks);
    }
}
开发者ID:pjsong,项目名称:WordPress,代码行数:20,代码来源:ms-blogs.php

示例7: _prime_site_caches

/**
 * Adds any sites from the given ids to the cache that do not already exist in cache.
 *
 * @since 4.6.0
 * @access private
 *
 * @see update_site_cache()
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $ids ID list.
 */
function _prime_site_caches($ids)
{
    global $wpdb;
    $non_cached_ids = _get_non_cached_ids($ids, 'sites');
    if (!empty($non_cached_ids)) {
        $fresh_sites = $wpdb->get_results(sprintf("SELECT * FROM {$wpdb->blogs} WHERE blog_id IN (%s)", join(",", array_map('intval', $non_cached_ids))));
        update_site_cache($fresh_sites);
    }
}
开发者ID:pbearne,项目名称:contrib2core,代码行数:21,代码来源:ms-blogs.php


注:本文中的_get_non_cached_ids函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。