Chore: Add username option for redis remote cache
This commit is contained in:
@@ -456,6 +456,8 @@ Example connstr: `addr=127.0.0.1:6379,pool_size=100,db=0,ssl=false`
|
||||
- `addr` is the host `:` port of the redis server.
|
||||
- `pool_size` (optional) is the number of underlying connections that can be made to redis.
|
||||
- `db` (optional) is the number identifier of the redis database you want to use.
|
||||
- `username` (optional) is the connection identifier to authenticate the current connection.
|
||||
- `password` (optional) is the connection secret to authenticate the current connection.
|
||||
- `ssl` (optional) is if SSL should be used to connect to redis server. The value may be `true`, `false`, or `insecure`. Setting the value to `insecure` skips verification of the certificate chain and hostname when making the connection.
|
||||
|
||||
#### memcache
|
||||
|
||||
@@ -39,6 +39,8 @@ func parseRedisConnStr(connStr string) (*redis.Options, error) {
|
||||
switch connKey {
|
||||
case "addr":
|
||||
options.Addr = connVal
|
||||
case "username":
|
||||
options.Username = connVal
|
||||
case "password":
|
||||
options.Password = connVal
|
||||
case "db":
|
||||
|
||||
@@ -16,11 +16,12 @@ func Test_parseRedisConnStr(t *testing.T) {
|
||||
ShouldErr bool
|
||||
}{
|
||||
"all redis options should parse": {
|
||||
"addr=127.0.0.1:6379,pool_size=100,db=1,password=grafanaRocks,ssl=false",
|
||||
"addr=127.0.0.1:6379,pool_size=100,db=1,username=grafana,password=grafanaRocks,ssl=false",
|
||||
&redis.Options{
|
||||
Addr: "127.0.0.1:6379",
|
||||
PoolSize: 100,
|
||||
DB: 1,
|
||||
Username: "grafana",
|
||||
Password: "grafanaRocks",
|
||||
Network: "tcp",
|
||||
TLSConfig: nil,
|
||||
|
||||
Reference in New Issue
Block a user