Parse redis backend url (#804)

As suggested by the go-redis client, parse the url to get the config.
This will fix problems, when the url contains a username and/or password.

Fixes #798

Signed-off-by: Christian Zunker <christian.zunker@codecentric.cloud>
This commit is contained in:
Christian Zunker
2021-01-21 08:08:53 +01:00
committed by GitHub
parent 0954f6b1bb
commit 1f17e71dce

View File

@@ -32,9 +32,11 @@ type Cache struct {
func NewCache(backend string) (Cache, error) {
if strings.HasPrefix(backend, "redis://") {
log.Logger.Infof("Redis cache: %s", backend)
redisCache := cache.NewRedisCache(&redis.Options{
Addr: strings.TrimPrefix(backend, "redis://"),
})
options, err := redis.ParseURL(backend)
if err != nil {
return Cache{}, err
}
redisCache := cache.NewRedisCache(options)
return Cache{Cache: redisCache}, nil
}
fsCache, err := cache.NewFSCache(utils.CacheDir())