debasishg/scala-redis — pull request #101 by timotta (2014-02-12 01:45:37+00:00)
Title: re-authenticate and re-select database when disconnect

When a client on a connection pool looses its connection to redis-server, is necessary to re-authenticate this client. The problem can be reproduced following these steps:

1. Edit your redis-server to have requiredpass:
```
sudo vim /etc/redis/redis.conf
requirepass foobared
```

2. Open sbt console and execute
```
import com.redis._
val p = new RedisClientPool("localhost", 6379, secret=Some("foobared"), maxIdle=1)
p.withClient { client => client.set("x","y") }
```

3. Do not close console and restart redis
```
sudo service redis-server restart
```

4. On the previously sbt console execute:
```
p.withClient { client => client.set("x","y") }
java.lang.Exception: NOAUTH Authentication required
```

The change in this commit correct this problem, re-authenticanting and re-selecting the redis database when connection was lost. Also, it includes a feature allowing single client to have database and authentication:

```
val r = new RedisClient("localhost", 6379, 0, Some("foobared"))
```