Skip Menu |

This queue is for tickets about the CHI-Driver-Redis CPAN distribution.

Report information
The Basics
Id: 97382
Status: resolved
Priority: 0/
Queue: CHI-Driver-Redis

People
Owner: ianburrell [...] gmail.com
Requestors: ianburrell [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.04
Fixed in: (no value)



Subject: Add support for password option
Redis servers can be configured to require a password for authentication. CHI::Driver::Redis should support "password" option that is passed to the Redis object.
From: ianburrell [...] gmail.com
Patch to add password option. Setting password for testing uses CHI_REDIS_PASSWORD environment variable.
Subject: redis-password.patch
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;
From: ianburrell [...] gmail.com
Added in 0.06.