[wp-trac] [WordPress Trac] #22661: Allow object caches to degrade gracefully
WordPress Trac
noreply at wordpress.org
Wed Feb 14 18:29:33 UTC 2018
#22661: Allow object caches to degrade gracefully
--------------------------+-----------------------------
Reporter: markjaquith | Owner:
Type: defect (bug) | Status: closed
Priority: normal | Milestone: Future Release
Component: Cache API | Version:
Severity: normal | Resolution: fixed
Keywords: 2nd-opinion | Focuses:
--------------------------+-----------------------------
Changes (by markjaquith):
* status: reopened => closed
* resolution: => fixed
Comment:
Replying to [comment:4 wonderboymusic]:
> Unless I'm missing something, we did this here: [25289].
You are right.
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:
{{{
if ( ! wp_using_ext_object_cache() ) {
require_once ( ABSPATH . WPINC . '/cache.php' );
}
}}}
So you can just wrap your `object-cache.php` content (including all the
function definitions) in a prerequisites check. Like:
{{{
if ( class_exists( 'Redis' ) ) {
// Original file contents here.
}
}}}
Or, better, move the object cache file you're using to `redis-object-
cache.php` and do:
{{{
if ( class_exists( 'Redis' ) ) {
include( __DIR__ . '/redis-object-cache.php' );
}
}}}
So you can keep the original file unadulterated.
Closing this, as the original intent ("allow custom object caches to
gracefully degrade") is possible now.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/22661#comment:21>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list