Conversation
Dao-Ho
left a comment
There was a problem hiding this comment.
Just suggestion comments on design and testing. Overall a great ship!! Otherwise LGTM 🚀
| ctx := context.Background() | ||
|
|
||
| // Test Set | ||
| err = Client.Set(ctx, "test_key", "test_value", 0).Err() |
There was a problem hiding this comment.
What happens to this key once the test finishes? I think we should clean this up here:
I'd add this after this line to ensure it cleans up the test insert properly
defer Client.Del(ctx, "test_key")
| log.Printf("Warning: Redis not available: %v", err) | ||
| } | ||
| defer redis.Close() | ||
|
|
There was a problem hiding this comment.
I would move this to be in InitApp itself, it's where we setup our storage and services upon starting the app.
| ) | ||
|
|
||
| // Client is the global Redis client that the whole app uses | ||
| var Client *redis.Client |
There was a problem hiding this comment.
I would be wary of having a global mutable variable in the package. It's better design for us to initialize the client in the parent function and pass the client in as a parameter (in this case, when we want to initialize for the app itself, the client can be initialized before we call InitRedis and passed in as a parameter)
Dao-Ho
left a comment
There was a problem hiding this comment.
Sorry, missed one more quick move on the file structure
| @@ -0,0 +1,54 @@ | |||
| package redis | |||
There was a problem hiding this comment.
I'd also move this file to
/internal/storage/redis/client.go
since Redis falls under storage
Description
Added Redis client setup so we can use it for caching and rate limiting later. The app won't crash if Redis isn't running; it logs a warning and keeps going.
Type of Change
Related Issue(s)
Closes #
Related to #
What Changed?
internal/redis/Testing & Validation
How this was tested
brew services start redisgo test ./internal/redis/- everything passedScreenshots/Recordings
Unfinished Work & Known Issues
Notes & Nuances
Pre-Merge Checklist
Code Quality
Testing & CI
Documentation
Reviewer Notes