Changeset 54423
- Timestamp:
- 10/08/2022 01:39:43 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/object-cache.php
r53829 r54423 39 39 global $wp_object_cache; 40 40 return $wp_object_cache->addByKey( $server_key, $key, $value, $group, $expiration ); 41 } 42 43 /** 44 * Adds multiple values to the cache in one call, if the cache keys don't already exist. 45 * 46 * @param array $items Array of keys and values to be added. 47 * @param string $group Optional. Where the cache contents are grouped. Default empty. 48 * @param int $expiration Optional. When to expire the cache contents, in seconds. 49 * Default 0 (no expiration). 50 * @return bool[] Array of return values, grouped by key. Each value is either 51 * true on success, or false if cache key and group already exist. 52 */ 53 function wp_cache_add_multiple( array $items, $group = '', $expiration = 0 ) { 54 global $wp_object_cache; 55 return $wp_object_cache->addMultiple( $items, $group, $expiration ); 41 56 } 42 57 … … 246 261 global $wp_object_cache; 247 262 return $wp_object_cache->deleteByKey( $server_key, $key, $group, $time ); 263 } 264 265 /** 266 * Deletes multiple values from the cache in one call. 267 * 268 * @param array $keys Array of keys under which the cache to deleted. 269 * @param string $group Optional. Where the cache contents are grouped. Default empty. 270 * @return bool[] Array of return values, grouped by key. Each value is either 271 * true on success, or false if the contents were not deleted. 272 */ 273 function wp_cache_delete_multiple( array $keys, $group = '' ) { 274 global $wp_object_cache; 275 return $wp_object_cache->deleteMultiple( $keys, $group ); 248 276 } 249 277 … … 441 469 442 470 /** 471 * Retrieves multiple values from the cache in one call. 472 * 473 * @param array $keys Array of keys under which the cache contents are stored. 474 * @param string $group Optional. Where the cache contents are grouped. Default empty. 475 * @param bool $force Optional. Whether to force an update of the local cache 476 * from the persistent cache. Default false. 477 * @return array Array of return values, grouped by key. Each value is either 478 * the cache contents on success, or false on failure. 479 */ 480 function wp_cache_get_multiple( $keys, $group = '', $force = false ) { 481 global $wp_object_cache; 482 return $wp_object_cache->getMultiple( $keys, $group, $force ); 483 } 484 485 /** 443 486 * Retrieves a Memcached option value. 444 487 * … … 718 761 global $wp_object_cache; 719 762 return $wp_object_cache->setMultiByKey( $server_key, $items, $groups, $expiration ); 763 } 764 765 /** 766 * Sets multiple values to the cache in one call. 767 * 768 * Differs from wp_cache_add_multiple() in that it will always write data. 769 * 770 * @param array $items Array of keys and values to be set. 771 * @param string $group Optional. Where the cache contents are grouped. Default empty. 772 * @param int $expiration Optional. When to expire the cache contents, in seconds. 773 * Default 0 (no expiration). 774 * @return bool[] Array of return values, grouped by key. Each value is either 775 * true on success, or false on failure. 776 */ 777 function wp_cache_set_multiple( array $items, $group = '', $expiration = 0 ) { 778 global $wp_object_cache; 779 return $wp_object_cache->setMultiple( $items, $group, $expiration ); 720 780 } 721 781 … … 958 1018 959 1019 /** 1020 * Adds multiple values to cache. 1021 * 1022 * @param array $items Array of keys and values to be added. 1023 * @param string $group Optional. Where the cache contents are grouped. Default empty. 1024 * @param int $expiration Optional. When to expire the cache contents, in seconds. 1025 * Default 0 (no expiration). 1026 * @return bool[] Array of return values, grouped by key. Each value is either 1027 * true on success, or false if cache key and group already exist. 1028 */ 1029 public function addMultiple( array $items, $group = '', $expiration = 0 ) { 1030 $values = array(); 1031 1032 foreach ( $items as $key => $value ) { 1033 $values[ $key ] = $this->add( $key, $value, $group, $expiration ); 1034 } 1035 1036 return $values; 1037 } 1038 1039 /** 960 1040 * Adds a single server to the list of Memcached servers. 961 1041 * … … 1258 1338 public function deleteByKey( $server_key, $key, $group = 'default', $time = 0 ) { 1259 1339 return $this->delete( $key, $group, $time, $server_key, true ); 1340 } 1341 1342 /** 1343 * Removes multiple items from the cache. 1344 * 1345 * @param array $keys Array of keys under which the cache to deleted. 1346 * @param string $group Optional. Where the cache contents are grouped. Default empty. 1347 * @return bool[] Array of return values, grouped by key. Each value is either 1348 * true on success, or false if the contents were not deleted. 1349 */ 1350 public function deleteMultiple( $keys, $group ) { 1351 $values = array(); 1352 1353 foreach ( $keys as $key ) { 1354 $values[ $key ] = $this->delete( $key, $group ); 1355 } 1356 1357 return $values; 1260 1358 } 1261 1359 … … 1538 1636 1539 1637 /** 1638 * Get multiple items from the cache. 1639 * 1640 * @param array $keys Array of keys under which the cache contents are stored. 1641 * @param string $group Optional. Where the cache contents are grouped. Default empty. 1642 * @param bool $force Optional. Whether to force an update of the local cache 1643 * from the persistent cache. Default false. 1644 * @return array Array of return values, grouped by key. Each value is either 1645 * the cache contents on success, or false on failure. 1646 */ 1647 public function getMultiple( $keys, $group = '', $force = false ) { 1648 $values = array(); 1649 1650 foreach ( $keys as $key ) { 1651 $found = null; 1652 $value = $this->get( $key, $group, $force, $found ); 1653 $values[ $key ] = $found ? $value : false; 1654 } 1655 1656 return $values; 1657 } 1658 1659 /** 1540 1660 * Retrieves a Memcached option value. 1541 1661 * … … 1951 2071 public function setMultiByKey( $server_key, $items, $groups = 'default', $expiration = 0 ) { 1952 2072 return $this->setMulti( $items, $groups, $expiration, $server_key, true ); 2073 } 2074 2075 /** 2076 * Sets multiple values in cache. 2077 * 2078 * @param array $items Array of keys and values to be set. 2079 * @param string $group Optional. Where the cache contents are grouped. Default empty. 2080 * @param int $expiration Optional. When to expire the cache contents, in seconds. 2081 * Default 0 (no expiration). 2082 * @return bool[] Array of return values, grouped by key. Each value is either 2083 * true on success, or false on failure. 2084 */ 2085 public function setMultiple( array $items, $group = '', $expiration = 0 ) { 2086 $values = array(); 2087 2088 foreach ( $items as $key => $value ) { 2089 $values[ $key ] = $this->set( $key, $value, $group, $expiration ); 2090 } 2091 2092 return $values; 1953 2093 } 1954 2094
Note: See TracChangeset
for help on using the changeset viewer.