Changeset 20089
- Timestamp:
- 03/02/2012 09:10:37 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/cache.php
r19712 r20089 104 104 * @param string $group Where the cache contents are grouped 105 105 * @param bool $force Whether to force an update of the local cache from the persistent cache (default is false) 106 * @param &bool $found Whether key was found in the cache. Disambiguates a return of false, a storable value. 106 107 * @return bool|mixed False on failure to retrieve contents or the cache 107 108 * contents on success 108 109 */ 109 function wp_cache_get( $key, $group = '', $force = false ) {110 global $wp_object_cache; 111 112 return $wp_object_cache->get( $key, $group, $force );110 function wp_cache_get( $key, $group = '', $force = false, &$found = null ) { 111 global $wp_object_cache; 112 113 return $wp_object_cache->get( $key, $group, $force, $found ); 113 114 } 114 115 … … 273 274 * Adds data to the cache if it doesn't already exist. 274 275 * 275 * @uses WP_Object_Cache:: getChecks to see if the cache already has data.276 * @uses WP_Object_Cache::_exists Checks to see if the cache already has data. 276 277 * @uses WP_Object_Cache::set Sets the data after the checking the cache 277 278 * contents existence. … … 289 290 return false; 290 291 291 if ( empty ($group) )292 if ( empty( $group ) ) 292 293 $group = 'default'; 293 294 294 if ( false !== $this->get($key, $group))295 if ( $this->_exists($key, $group) ) 295 296 return false; 296 297 … … 323 324 */ 324 325 function decr( $key, $offset = 1, $group = 'default' ) { 325 if ( ! isset( $this->cache[ $group ][ $key ]) )326 if ( ! $this->_exists( $key, $group ) ) 326 327 return false; 327 328 … … 355 356 */ 356 357 function delete($key, $group = 'default', $force = false) { 357 if ( empty ($group))358 if ( empty( $group ) ) 358 359 $group = 'default'; 359 360 360 if ( !$force && false === $this->get($key, $group))361 if ( ! $force && ! $this->_exists( $key, $group ) ) 361 362 return false; 362 363 363 unset ($this->cache[$group][$key]);364 unset( $this->cache[$group][$key] ); 364 365 return true; 365 366 } … … 395 396 * contents on success 396 397 */ 397 function get( $key, $group = 'default', $force = false ) {398 if ( empty ($group) )398 function get( $key, $group = 'default', $force = false, &$found = null ) { 399 if ( empty( $group ) ) 399 400 $group = 'default'; 400 401 401 if ( isset ($this->cache[$group][$key]) ) { 402 if ( $this->_exists( $key, $group ) ) { 403 $found = true; 402 404 $this->cache_hits += 1; 403 405 if ( is_object($this->cache[$group][$key]) ) … … 407 409 } 408 410 411 $found = false; 409 412 $this->cache_misses += 1; 410 413 return false; … … 422 425 */ 423 426 function incr( $key, $offset = 1, $group = 'default' ) { 424 if ( ! isset( $this->cache[ $group ][ $key ] ) ) 427 if ( empty( $group ) ) 428 $group = 'default'; 429 430 if ( ! $this->_exists( $key, $group ) ) 425 431 return false; 426 432 … … 451 457 */ 452 458 function replace($key, $data, $group = 'default', $expire = '') { 453 if ( empty ($group))459 if ( empty( $group ) ) 454 460 $group = 'default'; 455 461 456 if ( false === $this->get($key, $group) )462 if ( ! $this->_exists( $key, $group ) ) 457 463 return false; 458 464 … … 494 500 */ 495 501 function set($key, $data, $group = 'default', $expire = '') { 496 if ( empty ($group) )502 if ( empty( $group ) ) 497 503 $group = 'default'; 498 499 if ( null === $data )500 $data = '';501 504 502 505 if ( is_object($data) ) … … 528 531 529 532 /** 533 * Utility function to determine whether a key exists in the cache. 534 * @access private 535 */ 536 protected function _exists($key, $group) { 537 return is_array( $this->cache[$group] ) && array_key_exists( $key, $this->cache[$group] ); 538 } 539 540 /** 530 541 * Sets up object properties; PHP 5 style constructor 531 542 *
Note: See TracChangeset
for help on using the changeset viewer.