Changeset 13066 for trunk/wp-includes/cache.php
- Timestamp:
- 02/12/2010 05:06:43 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/cache.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/cache.php
r13054 r13066 150 150 */ 151 151 function wp_cache_add_global_groups( $groups ) { 152 // Default cache doesn't persist so nothing to do here. 153 return; 152 global $wp_object_cache; 153 154 return $wp_object_cache->add_global_groups($groups); 154 155 } 155 156 … … 164 165 // Default cache doesn't persist so nothing to do here. 165 166 return; 167 } 168 169 /** 170 * Reset internal cache keys and structures. If the cache backend uses global blog or site IDs as part of its cache keys, 171 * this function instructs the backend to reset those keys and perform any cleanup since blog or site IDs have changed since cache init. 172 * 173 * @since 2.6.0 174 * 175 * @param string|array $groups A group or an array of groups to add 176 */ 177 function wp_cache_reset() { 178 global $wp_object_cache; 179 180 return $wp_object_cache->reset(); 166 181 } 167 182 … … 219 234 */ 220 235 var $cache_misses = 0; 236 237 /** 238 * List of global groups 239 * 240 * @var array 241 * @access protected 242 * @since 3.0.0 243 */ 244 var $global_groups = array(); 221 245 222 246 /** … … 235 259 * @return bool False if cache ID and group already exists, true on success 236 260 */ 237 function add( $id, $data, $group = 'default', $expire = '') {238 if ( empty ($group))261 function add( $id, $data, $group = 'default', $expire = '' ) { 262 if ( empty ($group) ) 239 263 $group = 'default'; 240 264 … … 243 267 244 268 return $this->set($id, $data, $group, $expire); 269 } 270 271 /** 272 * Sets the list of global groups. 273 * 274 * @since 3.0.0 275 * 276 * @param array $groups List of groups that are global. 277 */ 278 function add_global_groups( $groups ) { 279 $groups = (array) $groups; 280 281 $this->global_groups = array_merge($this->global_groups, $groups); 282 $this->global_groups = array_unique($this->global_groups); 245 283 } 246 284 … … 309 347 */ 310 348 function get($id, $group = 'default') { 311 if ( empty ($group))349 if ( empty ($group) ) 312 350 $group = 'default'; 313 351 314 if ( isset ($this->cache[$group][$id])) {352 if ( isset ($this->cache[$group][$id]) ) { 315 353 $this->cache_hits += 1; 316 354 if ( is_object($this->cache[$group][$id]) ) … … 344 382 $group = 'default'; 345 383 346 if ( false === $this->get($id, $group))384 if ( false === $this->get($id, $group) ) 347 385 return false; 348 386 349 387 return $this->set($id, $data, $group, $expire); 388 } 389 390 /** 391 * Reset keys 392 * 393 * @since 3.0.0 394 */ 395 function reset() { 396 // Clear out non-global caches since the blog ID has changed. 397 foreach ( array_keys($this->cache) as $group ) { 398 if ( !in_array($group, $this->global_groups) ) 399 unset($this->cache[$group]); 400 } 350 401 } 351 402 … … 371 422 */ 372 423 function set($id, $data, $group = 'default', $expire = '') { 373 if ( empty ($group))424 if ( empty ($group) ) 374 425 $group = 'default'; 375 426 376 if ( NULL === $data)427 if ( NULL === $data ) 377 428 $data = ''; 378 429 … … 382 433 $this->cache[$group][$id] = $data; 383 434 384 if (isset($this->non_existent_objects[$group][$id]))435 if ( isset($this->non_existent_objects[$group][$id]) ) 385 436 unset ($this->non_existent_objects[$group][$id]); 386 437
Note: See TracChangeset
for help on using the changeset viewer.