[wp-trac] [WordPress Trac] #22661: Allow object caches to degrade gracefully

WordPress Trac noreply at wordpress.org
Wed Feb 14 19:24:50 UTC 2018


#22661: Allow object caches to degrade gracefully
--------------------------+-----------------------------
 Reporter:  markjaquith   |       Owner:
     Type:  defect (bug)  |      Status:  reopened
 Priority:  normal        |   Milestone:  Future Release
Component:  Cache API     |     Version:
 Severity:  normal        |  Resolution:
 Keywords:  2nd-opinion   |     Focuses:
--------------------------+-----------------------------
Changes (by jtsternberg):

 * status:  closed => reopened
 * resolution:  fixed =>


Comment:

 Replying to [comment:21 markjaquith]:
 > If your `object-cache.php` does not define the `wp_cache_init()`
 function, `wp_using_ext_object_cache( true );` will not be called, and
 this will run, loading WP's in-memory cache:

 I’m still seeing issues with this approach, but only on multisite. Because
 `ms-settings.php` calls `wp_start_object_cache()` ''again'', it makes WP
 think an external object-cache exists: http://b.ustin.co/zc3syn

 So it means WP did load it's default implementation (`wp-
 includes/cache.php`), which is good as some cache will be used some times,
 but `$_wp_using_ext_object_cache` is set to true, which is bad because
 `wp_using_ext_object_cache()` is used quite a bit to determine if some
 things will attempt to be cached to a persistent object cache (causing
 extra queries), and to determine if some things don't need to be cached
 (causing extra queries). So something like this
 https://github.com/jtsternberg/object-cache.php-replacement/blob/master
 /object-cache.php is needed to reset that global during the first
 available hook.

 It might be a decent solution for `wp_using_ext_object_cache()` to have a
 filter, as I think you could then override it for this scenario.

 OR, allow the `object-cache.php` file to define `define(
 'USING_EXT_OBJECT_CACHE', false );` which could override any logic that
 occurs downstream.
 Then wp_using_ext_object_cache would look something like:
 {{{
 function wp_using_ext_object_cache( $using = null ) {
         global $_wp_using_ext_object_cache;
         $current_using = $_wp_using_ext_object_cache;

         if ( defined( 'USING_EXT_OBJECT_CACHE' ) ) {
                 $using = USING_EXT_OBJECT_CACHE;
         }

         if ( null !== $using ) {
                 $_wp_using_ext_object_cache = $using;
         }
         return $current_using;
 }
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/22661#comment:22>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list