Ticket #20875: 20875.10.diff
| File 20875.10.diff, 3.4 KB (added by , 6 years ago) |
|---|
-
src/wp-includes/cache.php
127 127 } 128 128 129 129 /** 130 * Gets multiple values from cache in one call. 131 * 132 * @since 5.4.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 * 132 150 * @since 3.3.0 -
src/wp-includes/class-wp-object-cache.php
303 303 } 304 304 305 305 /** 306 * Retrieves multiple values from the cache. 307 * 308 * @since 5.4.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 * 308 329 * @since 3.3.0 -
src/wp-includes/load.php
614 614 wp_redirect( $link ); 615 615 die(); 616 616 } 617 618 if ( ! function_exists( 'wp_cache_get_multiple' ) ) { 619 require_once( ABSPATH . WPINC . '/cache-compat.php' ); 620 } 617 621 } 618 622 619 623 /** -
tests/phpunit/tests/cache.php
315 315 // Make sure $fake_key is not stored. 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 } -
tests/phpunit/tests/pluggable.php
290 290 'force' => false, 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', 295 300 'offset' => 1,