Skip to content

Comments

Tarika/redis setup#118

Open
tars919 wants to merge 3 commits intomainfrom
tarika/redis-setup
Open

Tarika/redis setup#118
tars919 wants to merge 3 commits intomainfrom
tarika/redis-setup

Conversation

@tars919
Copy link
Contributor

@tars919 tars919 commented Feb 10, 2026

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

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactoring (code improvement without changing functionality)
  • Documentation update
  • Configuration/infrastructure change
  • Performance improvement
  • Test coverage improvement

Related Issue(s)

Closes #
Related to #

What Changed?

  • Created Redis client package in internal/redis/
  • Added Redis initialization to main.go
  • Added REDIS_ADDR and REDIS_PASSWORD to .env.sample
  • Wrote tests for the Redis client
  • Updated dependencies (go.mod/go.sum)

Testing & Validation

How this was tested

  1. Installed and started Redis locally with brew services start redis
  2. Ran go test ./internal/redis/ - everything passed
  3. Created a quick test script to make sure I could actually store/retrieve data from Redis
  4. Stopped Redis to make sure the app doesn't crash when it's not available - just logs a warning
  5. CI is passing

Screenshots/Recordings

Unfinished Work & Known Issues

  • None, this PR is complete and production-ready
  • The following items are intentionally deferred:



Notes & Nuances



Pre-Merge Checklist

Code Quality

  • Code follows the project's style guidelines and conventions
  • Self-review completed (I've reviewed my own code for obvious issues)
  • No debugging code, console logs, or commented-out code left behind
  • No merge conflicts with the base branch
  • Meaningful commit messages that explain the "why"

Testing & CI

  • All CI checks are passing
  • All new and existing tests pass locally
  • Test coverage hasn't decreased (or decrease is justified)
  • Linting passes without errors

Documentation

  • Code is self-documenting or includes helpful comments for complex logic
  • API documentation updated (if backend endpoints changed)
  • Type definitions are accurate and up-to-date

Reviewer Notes

  • Areas needing extra attention: ...
  • Questions for reviewers: ...

Copy link
Contributor

@Dao-Ho Dao-Ho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Contributor

@Dao-Ho Dao-Ho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, missed one more quick move on the file structure

@@ -0,0 +1,54 @@
package redis
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd also move this file to
/internal/storage/redis/client.go

since Redis falls under storage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants