Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Altynbaev Dinislam committed Nov 10, 2023
1 parent d85b6aa commit 10491d0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/lib/cache/cache.go
Expand Up @@ -32,8 +32,10 @@ const (
Memory = "memory"
// Redis the cache name of redis
Redis = "redis"
RedisTLS = "rediss"
// RedisSentinel the cache name of redis sentinel
RedisSentinel = "redis+sentinel"
RedisSentinelTLS = "rediss+sentinel"
)

var (
Expand Down
26 changes: 18 additions & 8 deletions src/lib/cache/redis/redis.go
Expand Up @@ -186,10 +186,15 @@ func New(opts cache.Options) (cache.Cache, error) {
return nil, err
}

if u.Scheme == "rediss" {
rdbOpts.TLSConfig = &tls.Config{
MinVersion: tls.VersionTLS12,
}
client = redis.NewClient(rdbOpts)
case cache.RedisTLS:
rdbOpts, err := redis.ParseURL(u.String())
if err != nil {
return nil, err
}

rdbOpts.TLSConfig = &tls.Config{
MinVersion: tls.VersionTLS13,
}
client = redis.NewClient(rdbOpts)
case cache.RedisSentinel:
Expand All @@ -198,10 +203,15 @@ func New(opts cache.Options) (cache.Cache, error) {
return nil, err
}

if u.Scheme == "rediss" {
failoverOpts.TLSConfig = &tls.Config{
MinVersion: tls.VersionTLS12,
}
client = redis.NewFailoverClient(failoverOpts)
case cache.RedisSentinelTLS:
failoverOpts, err := ParseSentinelURL(u.String())
if err != nil {
return nil, err
}

failoverOpts.TLSConfig = &tls.Config{
MinVersion: tls.VersionTLS13,
}
client = redis.NewFailoverClient(failoverOpts)
default:
Expand Down

0 comments on commit 10491d0

Please sign in to comment.