debasishg / scala-redis

A scala library for connecting to a redis server, or a cluster of redis nodes using consistent hashing on the client side.
1.02k stars 219 forks source link

How to add password to RedisClientPool? #282

Open AthanatiusC opened 2 years ago

AthanatiusC commented 2 years ago

Hello, i have a code which uses RedisClientPool, but it does not integrate any kind of authentication yet. But now we need to change it into using authentication. So i wonder can i add password parameter into RedisClientPool? If so, may i get some example?

Thank you!

noahlz commented 2 years ago

RedisClientPool has a constructor parameter called secret which serves as the password parameter.

noahlz commented 2 years ago

@AthanatiusC can you please provide more details? I might be seeing a similar issue where my RedisClientPool is failing with java.lang.Exception: NOAUTH Authentication required.

noahlz commented 2 years ago

I added unit tests in a PR that prove that RedisClientPool supports authentication properly.

There is an issue with RedisClient in the new-added BATCH mode, but that's unrelated to this.

AthanatiusC commented 2 years ago

Hello, Thank you very much for the kind reply. I have not been looking at email for the past few days. Thanks to your help of Secret parameter, i have been successfully use RedisClientPool with password... there was some edge case where authentication failed but it was just my workplace environment failure.

Thank you!

AthanatiusC commented 2 years ago

If anyone were to encounter some difficulties constructing the pool. Here is some code i have been successfully use the pool with

lazy val redisClientPool = new RedisClientPool(redisServerUrl, redisPort, database = redisDatabaseName,secret=Some(redisPassword))