Skip to content
Snippets Groups Projects
Commit d532386f authored by Hans Kuijpers's avatar Hans Kuijpers
Browse files

added authentication to connect with Redis

I have to use authentication to connect with Redis. (hosting is using PHPRedis instead of PRedis)
parent 7b2d176a
No related branches found
No related tags found
No related merge requests found
...@@ -320,6 +320,9 @@ class WP_Object_Cache { ...@@ -320,6 +320,9 @@ class WP_Object_Cache {
if ( defined( 'WP_REDIS_BACKEND_PORT' ) && WP_REDIS_BACKEND_PORT ) { if ( defined( 'WP_REDIS_BACKEND_PORT' ) && WP_REDIS_BACKEND_PORT ) {
$redis['port'] = WP_REDIS_BACKEND_PORT; $redis['port'] = WP_REDIS_BACKEND_PORT;
} }
if ( defined( 'WP_REDIS_BACKEND_AUTH' ) && WP_REDIS_BACKEND_AUTH ) {
$redis['auth'] = WP_REDIS_BACKEND_AUTH;
}
if ( defined( 'WP_REDIS_BACKEND_DB' ) && WP_REDIS_BACKEND_DB ) { if ( defined( 'WP_REDIS_BACKEND_DB' ) && WP_REDIS_BACKEND_DB ) {
$redis['database'] = WP_REDIS_BACKEND_DB; $redis['database'] = WP_REDIS_BACKEND_DB;
} }
...@@ -329,6 +332,10 @@ class WP_Object_Cache { ...@@ -329,6 +332,10 @@ class WP_Object_Cache {
try { try {
$this->redis = new Redis(); $this->redis = new Redis();
$this->redis->connect( $redis['host'], $redis['port'] ); $this->redis->connect( $redis['host'], $redis['port'] );
if ( isset( $redis['auth'] ) ) {
$this->redis->auth( $redis['auth'] );
}
if ( isset( $redis['database'] ) ) { if ( isset( $redis['database'] ) ) {
$this->redis->select( $redis['database'] ); $this->redis->select( $redis['database'] );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment