From 8059987098e391463a43bf8d1b11ac3ec9e586ab Mon Sep 17 00:00:00 2001 From: Tim Nolte Date: Fri, 10 Apr 2020 14:54:09 -0400 Subject: [PATCH] * Adds support for specifying the Redis instance database via environment/server variables. --- cli.php | 14 ++++++++------ object-cache.php | 12 +++++++----- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/cli.php b/cli.php index 46ade8d..fa94e67 100644 --- a/cli.php +++ b/cli.php @@ -15,15 +15,17 @@ public function cli() { # Attempt to automatically load Pantheon's Redis config from the env. if ( isset( $_SERVER['CACHE_HOST'] ) ) { $redis_server = array( - 'host' => $_SERVER['CACHE_HOST'], - 'port' => $_SERVER['CACHE_PORT'], - 'auth' => $_SERVER['CACHE_PASSWORD'], + 'host' => $_SERVER['CACHE_HOST'], + 'port' => $_SERVER['CACHE_PORT'], + 'auth' => $_SERVER['CACHE_PASSWORD'], + 'database' => isset( $_SERVER['CACHE_DB'] ) ? $_SERVER['CACHE_DB'] : 0, ); } else { $redis_server = array( - 'host' => '127.0.0.1', - 'port' => 6379, - 'auth' => '', + 'host' => '127.0.0.1', + 'port' => 6379, + 'auth' => '', + 'database' => 0, ); } } diff --git a/object-cache.php b/object-cache.php index f75e576..a42a989 100644 --- a/object-cache.php +++ b/object-cache.php @@ -1066,14 +1066,16 @@ public function build_client_parameters( $redis_server ) { // Attempt to automatically load Pantheon's Redis config from the env. if ( isset( $_SERVER['CACHE_HOST'] ) ) { $redis_server = array( - 'host' => $_SERVER['CACHE_HOST'], - 'port' => $_SERVER['CACHE_PORT'], - 'auth' => $_SERVER['CACHE_PASSWORD'], + 'host' => $_SERVER['CACHE_HOST'], + 'port' => $_SERVER['CACHE_PORT'], + 'auth' => $_SERVER['CACHE_PASSWORD'], + 'database' => isset( $_SERVER['CACHE_DB'] ) ? $_SERVER['CACHE_DB'] : 0, ); } else { $redis_server = array( - 'host' => '127.0.0.1', - 'port' => 6379, + 'host' => '127.0.0.1', + 'port' => 6379, + 'database' => 0, ); } }