refactor: abstract redis cache param for code cleanliness#90
Merged
joshydavid merged 1 commit intomasterfrom Jul 27, 2025
Merged
refactor: abstract redis cache param for code cleanliness#90joshydavid merged 1 commit intomasterfrom
joshydavid merged 1 commit intomasterfrom
Conversation
Signed-off-by: joshydavid <cxang.2022@scis.smu.edu.sg>
There was a problem hiding this comment.
Pull Request Overview
This PR refactors Redis cache annotation parameters to improve code maintainability by extracting the hardcoded #userId parameter into a constant. This eliminates duplicate string literals and centralizes cache parameter definitions.
- Introduces a new constant
CACHE_PARAMin theRedisCacheKeyclass to represent the#userIdcache key parameter - Updates
@Cacheableannotations in service implementations to use the new constant instead of hardcoded strings
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| backend/src/main/java/com/bi/constant/RedisCacheKey.java | Adds new CACHE_PARAM constant for cache key parameter |
| backend/src/main/java/com/bi/service/impl/RecipeServiceImpl.java | Updates @Cacheable annotation to use the new constant |
| backend/src/main/java/com/bi/service/impl/CoffeeListingServiceImpl.java | Updates @Cacheable annotation to use the new constant |
Comments suppressed due to low confidence (1)
backend/src/main/java/com/bi/constant/RedisCacheKey.java:8
- [nitpick] The constant name
CACHE_PARAMis too generic. Consider a more descriptive name likeUSER_ID_CACHE_KEYorUSER_ID_PARAMto clearly indicate this parameter is specifically for user ID-based caching.
public static final String CACHE_PARAM = "#userId";
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
What type of PR is this?
Desktop and mobile screenshots/recordings