Cache API: Reorder object cache functions and methods for consistency.

The original order was alphabetical, which became less obvious as newer functions got added, resulting in a somewhat random order.

This commits aims to organize the functions and related `WP_Object_Cache` methods in a more predictable order:

* `wp_cache_init()`
* `wp_cache_add()`
* `wp_cache_add_multiple()`
* `wp_cache_replace()`
* `wp_cache_set()`
* `wp_cache_set_multiple()`
* `wp_cache_get()`
* `wp_cache_get_multiple()`
* `wp_cache_delete()`
* `wp_cache_delete_multiple()`
* `wp_cache_incr()`
* `wp_cache_decr()`
* `wp_cache_flush()`
* `wp_cache_close()`
* `wp_cache_add_global_groups()`
* `wp_cache_add_non_persistent_groups()`
* `wp_cache_switch_to_blog()`
* `wp_cache_reset()`

Follow-up to [3011], [6543], [7986], [13066], [18580], [21403], [47938], [52700], [52703-52705].

See #54728, #54574.

git-svn-id: https://develop.svn.wordpress.org/trunk@52706 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2022-02-11 18:47:38 +00:00
parent 72cf1aa905
commit 5d7297d031
5 changed files with 484 additions and 485 deletions

View File

@@ -331,25 +331,6 @@ class Tests_Cache extends WP_UnitTestCase {
$this->assertFalse( wp_cache_get( $fake_key ) );
}
/**
* @ticket 20875
*/
public function test_get_multiple() {
wp_cache_set( 'foo1', 'bar', 'group1' );
wp_cache_set( 'foo2', 'bar', 'group1' );
wp_cache_set( 'foo1', 'bar', 'group2' );
$found = wp_cache_get_multiple( array( 'foo1', 'foo2', 'foo3' ), 'group1' );
$expected = array(
'foo1' => 'bar',
'foo2' => 'bar',
'foo3' => false,
);
$this->assertSame( $expected, $found );
}
/**
* @ticket 54574
*/
@@ -394,6 +375,25 @@ class Tests_Cache extends WP_UnitTestCase {
$this->assertSame( $expected, $found );
}
/**
* @ticket 20875
*/
public function test_wp_cache_get_multiple() {
wp_cache_set( 'foo1', 'bar', 'group1' );
wp_cache_set( 'foo2', 'bar', 'group1' );
wp_cache_set( 'foo1', 'bar', 'group2' );
$found = wp_cache_get_multiple( array( 'foo1', 'foo2', 'foo3' ), 'group1' );
$expected = array(
'foo1' => 'bar',
'foo2' => 'bar',
'foo3' => false,
);
$this->assertSame( $expected, $found );
}
/**
* @ticket 54574
*/