Skip to content

Commit

Permalink
#fix: support redis username for cache
Browse files Browse the repository at this point in the history
  • Loading branch information
circa10a committed Jul 13, 2024
1 parent fae120d commit 2f75670
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down
2 changes: 2 additions & 0 deletions cache/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
}),
Expand Down

0 comments on commit 2f75670

Please sign in to comment.