Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/01/2014 02:30:53 AM (12 years ago)
Author:
boonebgorges
Message:

When updating meta cache for a group of items, make sure empty values are cached

When updating the meta cache for, say, a group of activity items, it's possible
that some activity items won't have any metadata associated with them. In these
cases, we follow WP's update_meta_cache() by caching an empty array for that
item, so as to avoid cache misses.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-cache.php

    r7845 r8011  
    232232        }
    233233
    234         foreach ( $cache as $object_id => $cache_val ) {
    235             wp_cache_set( $object_id, $cache_val, $cache_group );
     234        foreach ( $uncached_ids as $uncached_id ) {
     235            // Cache empty values as well
     236            if ( ! isset( $cache[ $uncached_id ] ) ) {
     237                $cache[ $uncached_id ] = array();
     238            }
     239
     240            wp_cache_set( $uncached_id, $cache[ $uncached_id ], $cache_group );
    236241        }
    237242    }
Note: See TracChangeset for help on using the changeset viewer.