Make WordPress Core

Changeset 53763

Timestamp:
07/22/2022 08:50:31 PM (2 years ago)
Author:
spacedmonkey
Message:

Cache API: Add wp_cache_flush_group function.

Add a new plugable function called wp_cache_flush_group, that will allow developers to clear whole cache groups with a single call. Developers can detect if their current implementation of an object cache supports flushing by group, by calling wp_cache_supports_group_flush which returns true if it is supported. If the developers of the object cache drop-in has not implemented wp_cache_flush_group and wp_cache_supports_group_flush, these functions are polyfilled and wp_cache_supports_group_flush defaults to false.

Props Spacedmonkey, filosofo, ryan, sc0ttkclark, SergeyBiryukov, scribu, Ste_95, dd32, dhilditch, dougal, lucasbustamante, dg12345, tillkruess, peterwilsoncc, flixos90, pbearne.
Fixes #4476.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/cache-compat.php

    r53206 r53763  
    142142    }
    143143endif;
     144
     145
     146
     147
     148
     149
     150
     151
     152
     153
     154
     155
     156
     157
     158
     159
     160
     161
     162
     163
     164
     165
     166
     167
     168
     169
     170
     171
     172
     173
     174
     175
     176
     177
     178
     179
     180
     181
     182
     183
     184
     185
     186
     187
     188
     189
  • trunk/src/wp-includes/cache.php

    r53206 r53763  
    2121function wp_cache_init() {
    2222    $GLOBALS['wp_object_cache'] = new WP_Object_Cache();
     23
     24
     25
     26
     27
     28
     29
     30
     31
     32
     33
     34
     35
    2336}
    2437
     
    283296
    284297/**
     298
     299
     300
     301
     302
     303
     304
     305
     306
     307
     308
     309
     310
     311
     312
     313
     314
     315
     316
    285317 * Closes the cache.
    286318 *
  • trunk/src/wp-includes/class-wp-object-cache.php

    r52708 r53763  
    292292
    293293    /**
     294
     295
     296
     297
     298
     299
     300
     301
     302
     303
     304
     305
     306
     307
    294308     * Retrieves the cache contents, if it exists.
    295309     *
  • trunk/tests/phpunit/includes/object-cache.php

    r52976 r53763  
    744744    global $wp_object_cache;
    745745    $wp_object_cache = new WP_Object_Cache();
     746
     747
     748
     749
     750
     751
     752
     753
     754
     755
     756
    746757}
    747758
  • trunk/tests/phpunit/tests/cache.php

    r52706 r53763  
    416416        $this->assertSame( $expected, $found );
    417417    }
     418
     419
     420
     421
     422
     423
     424
     425
     426
     427
     428
     429
     430
     431
     432
     433
     434
     435
     436
     437
     438
     439
     440
     441
     442
     443
     444
     445
     446
     447
     448
     449
    418450}
  • trunk/tests/phpunit/tests/pluggable.php

    r53478 r53763  
    269269                    // wp-includes/cache.php:
    270270                    'wp_cache_init'                      => array(),
     271
    271272                    'wp_cache_add'                       => array(
    272273                        'key',
     
    328329                    'wp_cache_flush'                     => array(),
    329330                    'wp_cache_flush_runtime'             => array(),
     331
    330332                    'wp_cache_close'                     => array(),
    331333                    'wp_cache_add_global_groups'         => array( 'groups' ),
Note: See TracChangeset for help on using the changeset viewer.