Patch to add password option. Setting password for testing uses CHI_REDIS_PASSWORD environment variable.
diff --git a/lib/CHI/Driver/Redis.pm b/lib/CHI/Driver/Redis.pm
index cc5daec..0d2f1ee 100644
--- a/lib/CHI/Driver/Redis.pm
+++ b/lib/CHI/Driver/Redis.pm
@@ -33,7 +33,8 @@ sub _build_redis {
return Redis->new(
server => $params->{server} || '127.0.0.1:6379',
- debug => $params->{debug} || 0
+ debug => $params->{debug} || 0,
+ ($params->{password} ? ( password => $params->{password} ) : ()),
);
}
@@ -132,11 +133,7 @@ sub _verify_redis_connection {
};
try {
- my $params = $self->_params;
- my $redis = Redis->new(
- server => $params->{server} || '127.0.0.1:6379',
- debug => $params->{debug} || 0
- );
+ my $redis = $self->_build_redis();
if(obj($redis, 'Redis')) {
# We apparently connected, success!
$self->redis($redis);
diff --git a/lib/CHI/Driver/Redis/t/CHIDriverTests.pm b/lib/CHI/Driver/Redis/t/CHIDriverTests.pm
index b7fbd74..f6789dc 100644
--- a/lib/CHI/Driver/Redis/t/CHIDriverTests.pm
+++ b/lib/CHI/Driver/Redis/t/CHIDriverTests.pm
@@ -12,7 +12,8 @@ sub new_cache_options {
return (
$self->SUPER::new_cache_options(),
driver_class => 'CHI::Driver::Redis',
- server => '127.0.0.1:6379',
+ server => $ENV{CHI_REDIS_SERVER} || '127.0.0.1:6379',
+ ($ENV{CHI_REDIS_PASSWORD} ? ( password => $ENV{CHI_REDIS_PASSWORD} ) : ()),
);
}
@@ -24,4 +25,4 @@ sub clear_redis : Test(setup) {
$cache->redis->flushall;
}
-1;
\ No newline at end of file
+1;