Wordpress Redis plug-in

@ericosman
We should using the plugin hook to apply some define constant like "WP_REDIS_PATH" without touch "wp-config.php", isn't good idea ?

Code:
add_action('plugins_loaded', function() {
    if (defined('WP_REDIS_HOST') && (string) constant("WP_REDIS_HOST") !=="" ) {
        // Some redis already config, skip...
        return;
    }
    if (!defined('WP_REDIS_SCHEME')) {
        define('WP_REDIS_SCHEME', "unix");
    }
    if (!defined('WP_REDIS_PATH')) {
        define('WP_REDIS_PATH',  da_redis_socket_path() );
    }
}, 1); // Low priority (1) for earlier execution
 
Back
Top