Make WordPress Core


Ignore:
Timestamp:
12/06/2022 07:59:45 PM (19 months ago)
Author:
spacedmonkey
Message:

Tests: Change the wp_cache_get_multiple function to get cache keys in a single request.

Follow up from [54423].

Change the wp_cache_get_multiple function to call the getMulti method in the object cache object, to get cache keys in a single call to memcache. This speeds up test by loading caches faster.

Props spacedmonkey, SergeyBiryukov.
See #54864.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/object-cache.php

    r54448 r54942  
    324324 */
    325325function wp_cache_supports( $feature ) {
    326     return false;
     326    switch ( $feature ) {
     327        case 'get_multiple':
     328            return true;
     329        default:
     330            return false;
     331    }
    327332}
    328333
     
    483488function wp_cache_get_multiple( $keys, $group = '', $force = false ) {
    484489    global $wp_object_cache;
     490
     491    // Prime multiple keys in a single Memcached call.
     492    $wp_object_cache->getMulti( $keys, $group );
     493
    485494    return $wp_object_cache->getMultiple( $keys, $group, $force );
    486495}
     
    21622171            $keys = (array) $keys;
    21632172        }
     2173        $keys = array_values( $keys );
    21642174
    21652175        // If we have equal numbers of keys and groups, merge $keys[n] and $group[n].
Note: See TracChangeset for help on using the changeset viewer.