Chore: Add username option for redis remote cache (#101787)

* Chore: Add username option for redis remote cache

(cherry picked from commit 25e28dc85e)

* Chore: Update docs and config with sample Redis conn with user+pass

---------

Co-authored-by: Thomas Fournier <tfournier@evolves.fr>
This commit is contained in:
Matheus Macabu
2025-03-12 08:26:41 +01:00
committed by GitHub
co-authored by Thomas Fournier
parent cd7b66e2e8
commit 848d49e70f
5 changed files with 9 additions and 4 deletions
+2
View File
@@ -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":
+2 -1
View File
@@ -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,