From a2edac75b47555ffbe3d2a6132d39516a70bae88 Mon Sep 17 00:00:00 2001
From: Erick Hitter <ehitter@gmail.com>
Date: Thu, 27 Feb 2014 11:05:24 -0800
Subject: [PATCH] Allow default configuration to be overridden by constants in
 wp-config.php

Supports alternative Redis configurations without requiring hacks to the plugin file
---
 object-cache.php | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/object-cache.php b/object-cache.php
index 5f689f9..027814f 100644
--- a/object-cache.php
+++ b/object-cache.php
@@ -782,7 +782,23 @@ class WP_Object_Cache {
 	public function __construct() {
 		require_once 'predis/autoload.php';
 
-		$this->redis = new Predis\Client( '' );
+		$redis = array(
+			'host' => '127.0.0.1',
+			'port' => 6379,
+		);
+
+		if ( defined( 'WP_REDIS_BACKEND_HOST' ) && WP_REDIS_BACKEND_HOST ) {
+			$redis['host'] = WP_REDIS_BACKEND_HOST;
+		}
+		if ( defined( 'WP_REDIS_BACKEND_PORT' ) && WP_REDIS_BACKEND_PORT ) {
+			$redis['port'] = WP_REDIS_BACKEND_PORT;
+		}
+		if ( defined( 'WP_REDIS_BACKEND_DB' ) && WP_REDIS_BACKEND_DB ) {
+			$redis['database'] = WP_REDIS_BACKEND_DB;
+		}
+
+		$this->redis = new Predis\Client( $redis );
+		unset( $redis );
 
 		global $blog_id, $table_prefix;
 
-- 
GitLab