| | 117 | * Gets multiple values from cache in one call. |
| | 118 | * |
| | 119 | * Key/group association is handled by assuming all keys have the same group |
| | 120 | * if string or single value array is passed as the 'groups' value. If 'groups' |
| | 121 | * is an array with more than 1 value, then groups[n] corresponds with keys[n]. |
| | 122 | * If there are more 'keys' values then 'groups' values, remaining keys will be |
| | 123 | * pulled from the 'default' group. |
| | 124 | * |
| | 125 | * @since 3.6 |
| | 126 | * @uses $wp_object_cache Object Cache Class |
| | 127 | * @see WP_Object_Cache::get_multi() |
| | 128 | * |
| | 129 | * @param mixed $keys Array of keys associated with values. |
| | 130 | * @param mixed $groups Array of groups associated with keys. |
| | 131 | * @return array|bool Array of values organized into groups. |
| | 132 | */ |
| | 133 | function wp_cache_get_multi( $keys, $groups = '' ) { |
| | 134 | global $wp_object_cache; |
| | 135 | |
| | 136 | return $wp_object_cache->get_multi( $keys, $groups ); |
| | 137 | } |
| | 138 | |
| | 139 | /** |
| | 491 | * Gets multiple values from cache in one call. |
| | 492 | * |
| | 493 | * Key/group association is handled by assuming all keys have the same group |
| | 494 | * if string or single value array is passed as the 'groups' value. If 'groups' |
| | 495 | * is an array with more than 1 value, then groups[n] corresponds with keys[n]. |
| | 496 | * If there are more 'keys' values then 'groups' values, remaining keys will be |
| | 497 | * pulled from the 'default' group. |
| | 498 | * |
| | 499 | * @since 3.6 |
| | 500 | * |
| | 501 | * @param mixed $keys Keys associated with values. |
| | 502 | * @param mixed $groups Groups associated with keys. |
| | 503 | * @return array|bool Array of values |
| | 504 | */ |
| | 505 | function get_multi( $keys, $groups = 'default' ) { |
| | 506 | $values = array(); |
| | 507 | $keys = array_values( (array) $keys ); |
| | 508 | |
| | 509 | if ( is_array( $groups ) ) |
| | 510 | $groups = array_values( $groups ); |
| | 511 | |
| | 512 | foreach ( $keys as $key ) { |
| | 513 | if ( empty( $groups ) ) { |
| | 514 | $values[] = $this->get( $key ); |
| | 515 | } elseif ( ! is_array( $groups ) ) { |
| | 516 | $values[] = $this->get( $key, $groups ); |
| | 517 | } else { |
| | 518 | $group = array_shift( $groups ); |
| | 519 | if ( $group ) |
| | 520 | $values[] = $this->get( $key, $group ); |
| | 521 | else |
| | 522 | $values[] = $this->get( $key ); |
| | 523 | } |
| | 524 | } |
| | 525 | |
| | 526 | return $values; |
| | 527 | } |
| | 528 | |
| | 529 | /** |