clean_term_cache

The timeline below displays how wordpress function clean_term_cache has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.3

/**
 * Removes all of the term IDs from the cache.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb                           WordPress database abstraction object.
 * @global bool $_wp_suspend_cache_invalidation
 *
 * @param int|int[] $ids            Single or array of term IDs.
 * @param string    $taxonomy       Optional. Taxonomy slug. Can be empty, in which case the taxonomies of the passed
 *                                  term IDs will be used. Default empty.
 * @param bool      $clean_taxonomy Optional. Whether to clean taxonomy wide caches (true), or just individual
 *                                  term object caches (false). Default true.
 */
function clean_term_cache($ids, $taxonomy = '', $clean_taxonomy = true)
{
    global $wpdb, $_wp_suspend_cache_invalidation;
    if (!empty($_wp_suspend_cache_invalidation)) {
        return;
    }
    if (!is_array($ids)) {
        $ids = array($ids);
    }
    $taxonomies = array();
    // If no taxonomy, assume tt_ids.
    if (empty($taxonomy)) {
        $tt_ids = array_map('intval', $ids);
        $tt_ids = implode(', ', $tt_ids);
        $terms = $wpdb->get_results("SELECT term_id, taxonomy FROM {$wpdb->term_taxonomy} WHERE term_taxonomy_id IN ({$tt_ids})");
        $ids = array();
        foreach ((array) $terms as $term) {
            $taxonomies[] = $term->taxonomy;
            $ids[] = $term->term_id;
        }
        wp_cache_delete_multiple($ids, 'terms');
        $taxonomies = array_unique($taxonomies);
    } else {
        wp_cache_delete_multiple($ids, 'terms');
        $taxonomies = array($taxonomy);
    }
    foreach ($taxonomies as $taxonomy) {
        if ($clean_taxonomy) {
            clean_taxonomy_cache($taxonomy);
        }
        /**
         * Fires once after each taxonomy's term cache has been cleaned.
         *
         * @since 2.5.0
         * @since 4.5.0 Added the `$clean_taxonomy` parameter.
         *
         * @param array  $ids            An array of term IDs.
         * @param string $taxonomy       Taxonomy slug.
         * @param bool   $clean_taxonomy Whether or not to clean taxonomy-wide caches
         */
        do_action('clean_term_cache', $ids, $taxonomy, $clean_taxonomy);
    }
    wp_cache_set_terms_last_changed();
}

WordPress Version: 6.1

/**
 * Removes all of the term IDs from the cache.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb                           WordPress database abstraction object.
 * @global bool $_wp_suspend_cache_invalidation
 *
 * @param int|int[] $ids            Single or array of term IDs.
 * @param string    $taxonomy       Optional. Taxonomy slug. Can be empty, in which case the taxonomies of the passed
 *                                  term IDs will be used. Default empty.
 * @param bool      $clean_taxonomy Optional. Whether to clean taxonomy wide caches (true), or just individual
 *                                  term object caches (false). Default true.
 */
function clean_term_cache($ids, $taxonomy = '', $clean_taxonomy = true)
{
    global $wpdb, $_wp_suspend_cache_invalidation;
    if (!empty($_wp_suspend_cache_invalidation)) {
        return;
    }
    if (!is_array($ids)) {
        $ids = array($ids);
    }
    $taxonomies = array();
    // If no taxonomy, assume tt_ids.
    if (empty($taxonomy)) {
        $tt_ids = array_map('intval', $ids);
        $tt_ids = implode(', ', $tt_ids);
        $terms = $wpdb->get_results("SELECT term_id, taxonomy FROM {$wpdb->term_taxonomy} WHERE term_taxonomy_id IN ({$tt_ids})");
        $ids = array();
        foreach ((array) $terms as $term) {
            $taxonomies[] = $term->taxonomy;
            $ids[] = $term->term_id;
        }
        wp_cache_delete_multiple($ids, 'terms');
        $taxonomies = array_unique($taxonomies);
    } else {
        wp_cache_delete_multiple($ids, 'terms');
        $taxonomies = array($taxonomy);
    }
    foreach ($taxonomies as $taxonomy) {
        if ($clean_taxonomy) {
            clean_taxonomy_cache($taxonomy);
        }
        /**
         * Fires once after each taxonomy's term cache has been cleaned.
         *
         * @since 2.5.0
         * @since 4.5.0 Added the `$clean_taxonomy` parameter.
         *
         * @param array  $ids            An array of term IDs.
         * @param string $taxonomy       Taxonomy slug.
         * @param bool   $clean_taxonomy Whether or not to clean taxonomy-wide caches
         */
        do_action('clean_term_cache', $ids, $taxonomy, $clean_taxonomy);
    }
    wp_cache_set('last_changed', microtime(), 'terms');
}

WordPress Version: 5.5

/**
 * Will remove all of the term IDs from the cache.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb                           WordPress database abstraction object.
 * @global bool $_wp_suspend_cache_invalidation
 *
 * @param int|int[] $ids            Single or array of term IDs.
 * @param string    $taxonomy       Optional. Taxonomy slug. Can be empty, in which case the taxonomies of the passed
 *                                  term IDs will be used. Default empty.
 * @param bool      $clean_taxonomy Optional. Whether to clean taxonomy wide caches (true), or just individual
 *                                  term object caches (false). Default true.
 */
function clean_term_cache($ids, $taxonomy = '', $clean_taxonomy = true)
{
    global $wpdb, $_wp_suspend_cache_invalidation;
    if (!empty($_wp_suspend_cache_invalidation)) {
        return;
    }
    if (!is_array($ids)) {
        $ids = array($ids);
    }
    $taxonomies = array();
    // If no taxonomy, assume tt_ids.
    if (empty($taxonomy)) {
        $tt_ids = array_map('intval', $ids);
        $tt_ids = implode(', ', $tt_ids);
        $terms = $wpdb->get_results("SELECT term_id, taxonomy FROM {$wpdb->term_taxonomy} WHERE term_taxonomy_id IN ({$tt_ids})");
        $ids = array();
        foreach ((array) $terms as $term) {
            $taxonomies[] = $term->taxonomy;
            $ids[] = $term->term_id;
            wp_cache_delete($term->term_id, 'terms');
        }
        $taxonomies = array_unique($taxonomies);
    } else {
        $taxonomies = array($taxonomy);
        foreach ($taxonomies as $taxonomy) {
            foreach ($ids as $id) {
                wp_cache_delete($id, 'terms');
            }
        }
    }
    foreach ($taxonomies as $taxonomy) {
        if ($clean_taxonomy) {
            clean_taxonomy_cache($taxonomy);
        }
        /**
         * Fires once after each taxonomy's term cache has been cleaned.
         *
         * @since 2.5.0
         * @since 4.5.0 Added the `$clean_taxonomy` parameter.
         *
         * @param array  $ids            An array of term IDs.
         * @param string $taxonomy       Taxonomy slug.
         * @param bool   $clean_taxonomy Whether or not to clean taxonomy-wide caches
         */
        do_action('clean_term_cache', $ids, $taxonomy, $clean_taxonomy);
    }
    wp_cache_set('last_changed', microtime(), 'terms');
}

WordPress Version: 5.4

/**
 * Will remove all of the term ids from the cache.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb                           WordPress database abstraction object.
 * @global bool $_wp_suspend_cache_invalidation
 *
 * @param int|int[] $ids            Single or array of term IDs.
 * @param string    $taxonomy       Optional. Taxonomy slug. Can be empty, in which case the taxonomies of the passed
 *                                  term IDs will be used. Default empty.
 * @param bool      $clean_taxonomy Optional. Whether to clean taxonomy wide caches (true), or just individual
 *                                  term object caches (false). Default true.
 */
function clean_term_cache($ids, $taxonomy = '', $clean_taxonomy = true)
{
    global $wpdb, $_wp_suspend_cache_invalidation;
    if (!empty($_wp_suspend_cache_invalidation)) {
        return;
    }
    if (!is_array($ids)) {
        $ids = array($ids);
    }
    $taxonomies = array();
    // If no taxonomy, assume tt_ids.
    if (empty($taxonomy)) {
        $tt_ids = array_map('intval', $ids);
        $tt_ids = implode(', ', $tt_ids);
        $terms = $wpdb->get_results("SELECT term_id, taxonomy FROM {$wpdb->term_taxonomy} WHERE term_taxonomy_id IN ({$tt_ids})");
        $ids = array();
        foreach ((array) $terms as $term) {
            $taxonomies[] = $term->taxonomy;
            $ids[] = $term->term_id;
            wp_cache_delete($term->term_id, 'terms');
        }
        $taxonomies = array_unique($taxonomies);
    } else {
        $taxonomies = array($taxonomy);
        foreach ($taxonomies as $taxonomy) {
            foreach ($ids as $id) {
                wp_cache_delete($id, 'terms');
            }
        }
    }
    foreach ($taxonomies as $taxonomy) {
        if ($clean_taxonomy) {
            clean_taxonomy_cache($taxonomy);
        }
        /**
         * Fires once after each taxonomy's term cache has been cleaned.
         *
         * @since 2.5.0
         * @since 4.5.0 Added the `$clean_taxonomy` parameter.
         *
         * @param array  $ids            An array of term IDs.
         * @param string $taxonomy       Taxonomy slug.
         * @param bool   $clean_taxonomy Whether or not to clean taxonomy-wide caches
         */
        do_action('clean_term_cache', $ids, $taxonomy, $clean_taxonomy);
    }
    wp_cache_set('last_changed', microtime(), 'terms');
}

WordPress Version: 5.3

/**
 * Will remove all of the term ids from the cache.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb                           WordPress database abstraction object.
 * @global bool $_wp_suspend_cache_invalidation
 *
 * @param int|array $ids            Single or list of Term IDs.
 * @param string    $taxonomy       Optional. Can be empty and will assume `tt_ids`, else will use for context.
 *                                  Default empty.
 * @param bool      $clean_taxonomy Optional. Whether to clean taxonomy wide caches (true), or just individual
 *                                  term object caches (false). Default true.
 */
function clean_term_cache($ids, $taxonomy = '', $clean_taxonomy = true)
{
    global $wpdb, $_wp_suspend_cache_invalidation;
    if (!empty($_wp_suspend_cache_invalidation)) {
        return;
    }
    if (!is_array($ids)) {
        $ids = array($ids);
    }
    $taxonomies = array();
    // If no taxonomy, assume tt_ids.
    if (empty($taxonomy)) {
        $tt_ids = array_map('intval', $ids);
        $tt_ids = implode(', ', $tt_ids);
        $terms = $wpdb->get_results("SELECT term_id, taxonomy FROM {$wpdb->term_taxonomy} WHERE term_taxonomy_id IN ({$tt_ids})");
        $ids = array();
        foreach ((array) $terms as $term) {
            $taxonomies[] = $term->taxonomy;
            $ids[] = $term->term_id;
            wp_cache_delete($term->term_id, 'terms');
        }
        $taxonomies = array_unique($taxonomies);
    } else {
        $taxonomies = array($taxonomy);
        foreach ($taxonomies as $taxonomy) {
            foreach ($ids as $id) {
                wp_cache_delete($id, 'terms');
            }
        }
    }
    foreach ($taxonomies as $taxonomy) {
        if ($clean_taxonomy) {
            clean_taxonomy_cache($taxonomy);
        }
        /**
         * Fires once after each taxonomy's term cache has been cleaned.
         *
         * @since 2.5.0
         * @since 4.5.0 Added the `$clean_taxonomy` parameter.
         *
         * @param array  $ids            An array of term IDs.
         * @param string $taxonomy       Taxonomy slug.
         * @param bool   $clean_taxonomy Whether or not to clean taxonomy-wide caches
         */
        do_action('clean_term_cache', $ids, $taxonomy, $clean_taxonomy);
    }
    wp_cache_set('last_changed', microtime(), 'terms');
}

WordPress Version: 4.9

/**
 * Will remove all of the term ids from the cache.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 * @global bool $_wp_suspend_cache_invalidation
 *
 * @param int|array $ids            Single or list of Term IDs.
 * @param string    $taxonomy       Optional. Can be empty and will assume `tt_ids`, else will use for context.
 *                                  Default empty.
 * @param bool      $clean_taxonomy Optional. Whether to clean taxonomy wide caches (true), or just individual
 *                                  term object caches (false). Default true.
 */
function clean_term_cache($ids, $taxonomy = '', $clean_taxonomy = true)
{
    global $wpdb, $_wp_suspend_cache_invalidation;
    if (!empty($_wp_suspend_cache_invalidation)) {
        return;
    }
    if (!is_array($ids)) {
        $ids = array($ids);
    }
    $taxonomies = array();
    // If no taxonomy, assume tt_ids.
    if (empty($taxonomy)) {
        $tt_ids = array_map('intval', $ids);
        $tt_ids = implode(', ', $tt_ids);
        $terms = $wpdb->get_results("SELECT term_id, taxonomy FROM {$wpdb->term_taxonomy} WHERE term_taxonomy_id IN ({$tt_ids})");
        $ids = array();
        foreach ((array) $terms as $term) {
            $taxonomies[] = $term->taxonomy;
            $ids[] = $term->term_id;
            wp_cache_delete($term->term_id, 'terms');
        }
        $taxonomies = array_unique($taxonomies);
    } else {
        $taxonomies = array($taxonomy);
        foreach ($taxonomies as $taxonomy) {
            foreach ($ids as $id) {
                wp_cache_delete($id, 'terms');
            }
        }
    }
    foreach ($taxonomies as $taxonomy) {
        if ($clean_taxonomy) {
            clean_taxonomy_cache($taxonomy);
        }
        /**
         * Fires once after each taxonomy's term cache has been cleaned.
         *
         * @since 2.5.0
         * @since 4.5.0 Added the `$clean_taxonomy` parameter.
         *
         * @param array  $ids            An array of term IDs.
         * @param string $taxonomy       Taxonomy slug.
         * @param bool   $clean_taxonomy Whether or not to clean taxonomy-wide caches
         */
        do_action('clean_term_cache', $ids, $taxonomy, $clean_taxonomy);
    }
    wp_cache_set('last_changed', microtime(), 'terms');
}

WordPress Version: 4.5

/**
 * Will remove all of the term ids from the cache.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 * @global bool $_wp_suspend_cache_invalidation
 *
 * @param int|array $ids            Single or list of Term IDs.
 * @param string    $taxonomy       Optional. Can be empty and will assume `tt_ids`, else will use for context.
 *                                  Default empty.
 * @param bool      $clean_taxonomy Optional. Whether to clean taxonomy wide caches (true), or just individual
 *                                  term object caches (false). Default true.
 */
function clean_term_cache($ids, $taxonomy = '', $clean_taxonomy = true)
{
    global $wpdb, $_wp_suspend_cache_invalidation;
    if (!empty($_wp_suspend_cache_invalidation)) {
        return;
    }
    if (!is_array($ids)) {
        $ids = array($ids);
    }
    $taxonomies = array();
    // If no taxonomy, assume tt_ids.
    if (empty($taxonomy)) {
        $tt_ids = array_map('intval', $ids);
        $tt_ids = implode(', ', $tt_ids);
        $terms = $wpdb->get_results("SELECT term_id, taxonomy FROM {$wpdb->term_taxonomy} WHERE term_taxonomy_id IN ({$tt_ids})");
        $ids = array();
        foreach ((array) $terms as $term) {
            $taxonomies[] = $term->taxonomy;
            $ids[] = $term->term_id;
            wp_cache_delete($term->term_id, 'terms');
        }
        $taxonomies = array_unique($taxonomies);
    } else {
        $taxonomies = array($taxonomy);
        foreach ($taxonomies as $taxonomy) {
            foreach ($ids as $id) {
                wp_cache_delete($id, 'terms');
            }
        }
    }
    foreach ($taxonomies as $taxonomy) {
        if ($clean_taxonomy) {
            wp_cache_delete('all_ids', $taxonomy);
            wp_cache_delete('get', $taxonomy);
            delete_option("{$taxonomy}_children");
            // Regenerate {$taxonomy}_children
            _get_term_hierarchy($taxonomy);
        }
        /**
         * Fires once after each taxonomy's term cache has been cleaned.
         *
         * @since 2.5.0
         * @since 4.5.0 Added the `$clean_taxonomy` parameter.
         *
         * @param array  $ids            An array of term IDs.
         * @param string $taxonomy       Taxonomy slug.
         * @param bool   $clean_taxonomy Whether or not to clean taxonomy-wide caches
         */
        do_action('clean_term_cache', $ids, $taxonomy, $clean_taxonomy);
    }
    wp_cache_set('last_changed', microtime(), 'terms');
}

WordPress Version: 4.4

/**
 * Will remove all of the term ids from the cache.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 * @global bool $_wp_suspend_cache_invalidation
 *
 * @param int|array $ids            Single or list of Term IDs.
 * @param string    $taxonomy       Optional. Can be empty and will assume `tt_ids`, else will use for context.
 *                                  Default empty.
 * @param bool      $clean_taxonomy Optional. Whether to clean taxonomy wide caches (true), or just individual
 *                                  term object caches (false). Default true.
 */
function clean_term_cache($ids, $taxonomy = '', $clean_taxonomy = true)
{
    global $wpdb, $_wp_suspend_cache_invalidation;
    if (!empty($_wp_suspend_cache_invalidation)) {
        return;
    }
    if (!is_array($ids)) {
        $ids = array($ids);
    }
    $taxonomies = array();
    // If no taxonomy, assume tt_ids.
    if (empty($taxonomy)) {
        $tt_ids = array_map('intval', $ids);
        $tt_ids = implode(', ', $tt_ids);
        $terms = $wpdb->get_results("SELECT term_id, taxonomy FROM {$wpdb->term_taxonomy} WHERE term_taxonomy_id IN ({$tt_ids})");
        $ids = array();
        foreach ((array) $terms as $term) {
            $taxonomies[] = $term->taxonomy;
            $ids[] = $term->term_id;
            wp_cache_delete($term->term_id, 'terms');
        }
        $taxonomies = array_unique($taxonomies);
    } else {
        $taxonomies = array($taxonomy);
        foreach ($taxonomies as $taxonomy) {
            foreach ($ids as $id) {
                wp_cache_delete($id, 'terms');
            }
        }
    }
    foreach ($taxonomies as $taxonomy) {
        if ($clean_taxonomy) {
            wp_cache_delete('all_ids', $taxonomy);
            wp_cache_delete('get', $taxonomy);
            delete_option("{$taxonomy}_children");
            // Regenerate {$taxonomy}_children
            _get_term_hierarchy($taxonomy);
        }
        /**
         * Fires once after each taxonomy's term cache has been cleaned.
         *
         * @since 2.5.0
         *
         * @param array  $ids      An array of term IDs.
         * @param string $taxonomy Taxonomy slug.
         */
        do_action('clean_term_cache', $ids, $taxonomy);
    }
    wp_cache_set('last_changed', microtime(), 'terms');
}

WordPress Version: 4.3

/**
 * Will remove all of the term ids from the cache.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 * @global bool $_wp_suspend_cache_invalidation
 *
 * @param int|array $ids            Single or list of Term IDs.
 * @param string    $taxonomy       Optional. Can be empty and will assume `tt_ids`, else will use for context.
 *                                  Default empty.
 * @param bool      $clean_taxonomy Optional. Whether to clean taxonomy wide caches (true), or just individual
 *                                  term object caches (false). Default true.
 */
function clean_term_cache($ids, $taxonomy = '', $clean_taxonomy = true)
{
    global $wpdb, $_wp_suspend_cache_invalidation;
    if (!empty($_wp_suspend_cache_invalidation)) {
        return;
    }
    if (!is_array($ids)) {
        $ids = array($ids);
    }
    $taxonomies = array();
    // If no taxonomy, assume tt_ids.
    if (empty($taxonomy)) {
        $tt_ids = array_map('intval', $ids);
        $tt_ids = implode(', ', $tt_ids);
        $terms = $wpdb->get_results("SELECT term_id, taxonomy FROM {$wpdb->term_taxonomy} WHERE term_taxonomy_id IN ({$tt_ids})");
        $ids = array();
        foreach ((array) $terms as $term) {
            $taxonomies[] = $term->taxonomy;
            $ids[] = $term->term_id;
            wp_cache_delete($term->term_id, $term->taxonomy);
        }
        $taxonomies = array_unique($taxonomies);
    } else {
        $taxonomies = array($taxonomy);
        foreach ($taxonomies as $taxonomy) {
            foreach ($ids as $id) {
                wp_cache_delete($id, $taxonomy);
            }
        }
    }
    foreach ($taxonomies as $taxonomy) {
        if ($clean_taxonomy) {
            wp_cache_delete('all_ids', $taxonomy);
            wp_cache_delete('get', $taxonomy);
            delete_option("{$taxonomy}_children");
            // Regenerate {$taxonomy}_children
            _get_term_hierarchy($taxonomy);
        }
        /**
         * Fires once after each taxonomy's term cache has been cleaned.
         *
         * @since 2.5.0
         *
         * @param array  $ids      An array of term IDs.
         * @param string $taxonomy Taxonomy slug.
         */
        do_action('clean_term_cache', $ids, $taxonomy);
    }
    wp_cache_set('last_changed', microtime(), 'terms');
}

WordPress Version: 4.1

/**
 * Will remove all of the term ids from the cache.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|array $ids Single or list of Term IDs
 * @param string $taxonomy Can be empty and will assume tt_ids, else will use for context.
 * @param bool $clean_taxonomy Whether to clean taxonomy wide caches (true), or just individual term object caches (false). Default is true.
 */
function clean_term_cache($ids, $taxonomy = '', $clean_taxonomy = true)
{
    global $wpdb;
    if (!is_array($ids)) {
        $ids = array($ids);
    }
    $taxonomies = array();
    // If no taxonomy, assume tt_ids.
    if (empty($taxonomy)) {
        $tt_ids = array_map('intval', $ids);
        $tt_ids = implode(', ', $tt_ids);
        $terms = $wpdb->get_results("SELECT term_id, taxonomy FROM {$wpdb->term_taxonomy} WHERE term_taxonomy_id IN ({$tt_ids})");
        $ids = array();
        foreach ((array) $terms as $term) {
            $taxonomies[] = $term->taxonomy;
            $ids[] = $term->term_id;
            wp_cache_delete($term->term_id, $term->taxonomy);
        }
        $taxonomies = array_unique($taxonomies);
    } else {
        $taxonomies = array($taxonomy);
        foreach ($taxonomies as $taxonomy) {
            foreach ($ids as $id) {
                wp_cache_delete($id, $taxonomy);
            }
        }
    }
    foreach ($taxonomies as $taxonomy) {
        if ($clean_taxonomy) {
            wp_cache_delete('all_ids', $taxonomy);
            wp_cache_delete('get', $taxonomy);
            delete_option("{$taxonomy}_children");
            // Regenerate {$taxonomy}_children
            _get_term_hierarchy($taxonomy);
        }
        /**
         * Fires once after each taxonomy's term cache has been cleaned.
         *
         * @since 2.5.0
         *
         * @param array  $ids      An array of term IDs.
         * @param string $taxonomy Taxonomy slug.
         */
        do_action('clean_term_cache', $ids, $taxonomy);
    }
    wp_cache_set('last_changed', microtime(), 'terms');
}

WordPress Version: 3.9

/**
 * Will remove all of the term ids from the cache.
 *
 * @since 2.3.0
 * @uses $wpdb
 *
 * @param int|array $ids Single or list of Term IDs
 * @param string $taxonomy Can be empty and will assume tt_ids, else will use for context.
 * @param bool $clean_taxonomy Whether to clean taxonomy wide caches (true), or just individual term object caches (false). Default is true.
 */
function clean_term_cache($ids, $taxonomy = '', $clean_taxonomy = true)
{
    global $wpdb;
    if (!is_array($ids)) {
        $ids = array($ids);
    }
    $taxonomies = array();
    // If no taxonomy, assume tt_ids.
    if (empty($taxonomy)) {
        $tt_ids = array_map('intval', $ids);
        $tt_ids = implode(', ', $tt_ids);
        $terms = $wpdb->get_results("SELECT term_id, taxonomy FROM {$wpdb->term_taxonomy} WHERE term_taxonomy_id IN ({$tt_ids})");
        $ids = array();
        foreach ((array) $terms as $term) {
            $taxonomies[] = $term->taxonomy;
            $ids[] = $term->term_id;
            wp_cache_delete($term->term_id, $term->taxonomy);
        }
        $taxonomies = array_unique($taxonomies);
    } else {
        $taxonomies = array($taxonomy);
        foreach ($taxonomies as $taxonomy) {
            foreach ($ids as $id) {
                wp_cache_delete($id, $taxonomy);
            }
        }
    }
    foreach ($taxonomies as $taxonomy) {
        if ($clean_taxonomy) {
            wp_cache_delete('all_ids', $taxonomy);
            wp_cache_delete('get', $taxonomy);
            delete_option("{$taxonomy}_children");
            // Regenerate {$taxonomy}_children
            _get_term_hierarchy($taxonomy);
        }
        /**
         * Fires once after each taxonomy's term cache has been cleaned.
         *
         * @since 2.5.0
         *
         * @param array  $ids      An array of term IDs.
         * @param string $taxonomy Taxonomy slug.
         */
        do_action('clean_term_cache', $ids, $taxonomy);
    }
    wp_cache_set('last_changed', microtime(), 'terms');
}

WordPress Version: 3.7

/**
 * Will remove all of the term ids from the cache.
 *
 * @package WordPress
 * @subpackage Taxonomy
 * @since 2.3.0
 * @uses $wpdb
 *
 * @param int|array $ids Single or list of Term IDs
 * @param string $taxonomy Can be empty and will assume tt_ids, else will use for context.
 * @param bool $clean_taxonomy Whether to clean taxonomy wide caches (true), or just individual term object caches (false). Default is true.
 */
function clean_term_cache($ids, $taxonomy = '', $clean_taxonomy = true)
{
    global $wpdb;
    static $cleaned = array();
    if (!is_array($ids)) {
        $ids = array($ids);
    }
    $taxonomies = array();
    // If no taxonomy, assume tt_ids.
    if (empty($taxonomy)) {
        $tt_ids = array_map('intval', $ids);
        $tt_ids = implode(', ', $tt_ids);
        $terms = $wpdb->get_results("SELECT term_id, taxonomy FROM {$wpdb->term_taxonomy} WHERE term_taxonomy_id IN ({$tt_ids})");
        $ids = array();
        foreach ((array) $terms as $term) {
            $taxonomies[] = $term->taxonomy;
            $ids[] = $term->term_id;
            wp_cache_delete($term->term_id, $term->taxonomy);
        }
        $taxonomies = array_unique($taxonomies);
    } else {
        $taxonomies = array($taxonomy);
        foreach ($taxonomies as $taxonomy) {
            foreach ($ids as $id) {
                wp_cache_delete($id, $taxonomy);
            }
        }
    }
    foreach ($taxonomies as $taxonomy) {
        if (isset($cleaned[$taxonomy])) {
            continue;
        }
        $cleaned[$taxonomy] = true;
        if ($clean_taxonomy) {
            wp_cache_delete('all_ids', $taxonomy);
            wp_cache_delete('get', $taxonomy);
            delete_option("{$taxonomy}_children");
            // Regenerate {$taxonomy}_children
            _get_term_hierarchy($taxonomy);
        }
        do_action('clean_term_cache', $ids, $taxonomy);
    }
    wp_cache_set('last_changed', microtime(), 'terms');
}