Make WordPress Core


Ignore:
Timestamp:
02/11/2022 06:47:38 PM (2 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/cache.php

    r52702 r52706  
    333333
    334334    /**
    335      * @ticket 20875
    336      */
    337     public function test_get_multiple() {
    338         wp_cache_set( 'foo1', 'bar', 'group1' );
    339         wp_cache_set( 'foo2', 'bar', 'group1' );
    340         wp_cache_set( 'foo1', 'bar', 'group2' );
    341 
    342         $found = wp_cache_get_multiple( array( 'foo1', 'foo2', 'foo3' ), 'group1' );
    343 
    344         $expected = array(
    345             'foo1' => 'bar',
    346             'foo2' => 'bar',
    347             'foo3' => false,
    348         );
    349 
    350         $this->assertSame( $expected, $found );
    351     }
    352 
    353     /**
    354335     * @ticket 54574
    355336     */
     
    396377
    397378    /**
     379     * @ticket 20875
     380     */
     381    public function test_wp_cache_get_multiple() {
     382        wp_cache_set( 'foo1', 'bar', 'group1' );
     383        wp_cache_set( 'foo2', 'bar', 'group1' );
     384        wp_cache_set( 'foo1', 'bar', 'group2' );
     385
     386        $found = wp_cache_get_multiple( array( 'foo1', 'foo2', 'foo3' ), 'group1' );
     387
     388        $expected = array(
     389            'foo1' => 'bar',
     390            'foo2' => 'bar',
     391            'foo3' => false,
     392        );
     393
     394        $this->assertSame( $expected, $found );
     395    }
     396
     397    /**
    398398     * @ticket 54574
    399399     */
Note: See TracChangeset for help on using the changeset viewer.