Changeset 9336 for trunk/src/bp-xprofile/bp-xprofile-cache.php
- Timestamp:
- 01/09/2015 08:38:37 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-xprofile/bp-xprofile-cache.php
r9318 r9336 12 12 // Exit if accessed directly 13 13 if ( !defined( 'ABSPATH' ) ) exit; 14 15 /** 16 * Determine which xprofile fields do not have cached values for a user. 17 * 18 * @since BuddyPress (2.2.0) 19 * 20 * @param int $user_id User ID to check 21 * @param array $field_ids XProfile field IDs. 22 * @return array 23 */ 24 function bp_xprofile_get_non_cached_field_ids( $user_id = 0, $field_ids = array() ) { 25 $uncached_fields = array(); 26 27 foreach ( $field_ids as $field_id ) { 28 $field_id = (int) $field_id; 29 $cache_key = "{$user_id}:{$field_id}"; 30 if ( false === wp_cache_get( $cache_key, 'bp_xprofile_data' ) ) { 31 $uncached_fields[] = $field_id; 32 } 33 } 34 35 return $uncached_fields; 36 } 14 37 15 38 /** … … 41 64 'group' => array(), 42 65 'field' => array(), 43 'data' 66 'data' => array(), 44 67 ); 45 68 … … 171 194 */ 172 195 function xprofile_clear_profiledata_object_cache( $data_obj ) { 173 wp_cache_delete( $data_obj->field_id, 'bp_xprofile_data_' . $data_obj->user_id);174 } 175 add_action( 'xprofile_data_after_save', 'xprofile_clear_profiledata_object_cache' );196 wp_cache_delete( "{$data_obj->user_id}:{$data_obj->field_id}", 'bp_xprofile_data' ); 197 } 198 add_action( 'xprofile_data_after_save', 'xprofile_clear_profiledata_object_cache' ); 176 199 add_action( 'xprofile_data_after_delete', 'xprofile_clear_profiledata_object_cache' ); 177 200
Note: See TracChangeset
for help on using the changeset viewer.