From 2f75670a95a7b88ca72e8edf26c34d7a6ddaed54 Mon Sep 17 00:00:00 2001 From: circa10a Date: Sat, 13 Jul 2024 11:34:59 -0700 Subject: [PATCH] #fix: support redis username for cache --- README.md | 1 + cache/redis.go | 2 ++ 2 files changed, 3 insertions(+) diff --git a/README.md b/README.md index 2807f71..4bd1f65 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,7 @@ func main() { // Use Redis for caching RedisOptions: &geofencecache.RedisOptions{ Addr: "localhost:6379", + Username: "", // no username set Password: "", // no password set DB: 0, // use default DB }, diff --git a/cache/redis.go b/cache/redis.go index e276e91..cc55aee 100644 --- a/cache/redis.go +++ b/cache/redis.go @@ -17,6 +17,7 @@ type RedisCache struct { // RedisOptions holds redis configuration parameters. type RedisOptions struct { Addr string + Username string Password string DB int TTL time.Duration @@ -27,6 +28,7 @@ func NewRedisCache(redisOpts *RedisOptions) *RedisCache { return &RedisCache{ redisClient: redis.NewClient(&redis.Options{ Addr: redisOpts.Addr, + Username: redisOpts.Username, Password: redisOpts.Password, DB: redisOpts.DB, }),