mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-16 23:00:21 +00:00
Actually make use of wp_cache_add to avoid unnecessary cache writes. Props skeltoac. fixes #4138
git-svn-id: https://develop.svn.wordpress.org/trunk@5248 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -8,7 +8,7 @@ function get_all_category_ids() {
|
||||
|
||||
if ( ! $cat_ids = wp_cache_get('all_category_ids', 'category') ) {
|
||||
$cat_ids = $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories");
|
||||
wp_cache_set('all_category_ids', $cat_ids, 'category');
|
||||
wp_cache_add('all_category_ids', $cat_ids, 'category');
|
||||
}
|
||||
|
||||
return $cat_ids;
|
||||
@@ -139,7 +139,7 @@ function &get_categories($args = '') {
|
||||
reset ( $categories );
|
||||
|
||||
$cache[ $key ] = $categories;
|
||||
wp_cache_set( 'get_categories', $cache, 'category' );
|
||||
wp_cache_add( 'get_categories', $cache, 'category' );
|
||||
|
||||
$categories = apply_filters('get_categories', $categories, $r);
|
||||
return $categories;
|
||||
@@ -160,7 +160,7 @@ function &get_category(&$category, $output = OBJECT) {
|
||||
$category = (int) $category;
|
||||
if ( ! $_category = wp_cache_get($category, 'category') ) {
|
||||
$_category = $wpdb->get_row("SELECT * FROM $wpdb->categories WHERE cat_ID = '$category' LIMIT 1");
|
||||
wp_cache_set($category, $_category, 'category');
|
||||
wp_cache_add($category, $_category, 'category');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user