Changeset 47938
- Timestamp:
- 06/09/2020 07:45:27 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/cache.php
r47197 r47938 128 128 129 129 /** 130 * Gets multiple values from cache in one call. 131 * 132 * @since 5.5.0 133 * @see WP_Object_Cache::get_multiple() 134 * 135 * @param array $keys Array of keys to get from group. 136 * @param string $group Optional. Where the cache contents are grouped. Default empty. 137 * @param bool $force Optional. Whether to force an update of the local cache from the persistent 138 * cache. Default false. 139 * @return array|bool Array of values. 140 */ 141 function wp_cache_get_multiple( $keys, $group = '', $force = false ) { 142 global $wp_object_cache; 143 144 return $wp_object_cache->get_multiple( $keys, $group, $force ); 145 } 146 147 /** 130 148 * Increment numeric cache item's value 131 149 * -
trunk/src/wp-includes/class-wp-object-cache.php
r47637 r47938 304 304 305 305 /** 306 * Retrieves multiple values from the cache. 307 * 308 * @since 5.5.0 309 * 310 * @param array $keys Array of keys to fetch. 311 * @param bool $force Optional. Unused. Whether to force a refetch rather than relying on the local 312 * cache. Default false. 313 * 314 * @return array Array of values organized into groups. 315 */ 316 public function get_multiple( $keys, $group = 'default', $force = false ) { 317 $values = array(); 318 319 foreach ( $keys as $key ) { 320 $values[ $key ] = $this->get( $key, $group, $force ); 321 } 322 323 return $values; 324 } 325 326 /** 306 327 * Increments numeric cache item's value. 307 328 * -
trunk/src/wp-includes/load.php
r47919 r47938 629 629 } 630 630 631 require_once( ABSPATH . WPINC . '/cache-compat.php' ); 632 631 633 /* 632 634 * If cache supports reset, reset instead of init if already -
trunk/tests/phpunit/tests/cache.php
r47122 r47938 316 316 $this->assertFalse( wp_cache_get( $fake_key ) ); 317 317 } 318 319 /** 320 * @ticket 20875 321 */ 322 public function test_get_multiple() { 323 wp_cache_set( 'foo1', 'bar', 'group1' ); 324 wp_cache_set( 'foo2', 'bar', 'group1' ); 325 wp_cache_set( 'foo1', 'bar', 'group2' ); 326 327 $found = wp_cache_get_multiple( array( 'foo1', 'foo2', 'foo3', ), 'group1' ); 328 329 $expected = array( 330 'foo1' => 'bar', 331 'foo2' => 'bar', 332 'foo3' => false, 333 ); 334 335 $this->assertSame( $expected, $found ); 336 } 318 337 } -
trunk/tests/phpunit/tests/pluggable.php
r47122 r47938 291 291 'found' => null, 292 292 ), 293 'wp_cache_get_multiple' => array( 294 'keys', 295 'group' => '', 296 'force' => false, 297 ), 293 298 'wp_cache_incr' => array( 294 299 'key',
Note: See TracChangeset
for help on using the changeset viewer.