feat: Implement Spring Cache for Account Service Transaction Retrieval#3
Open
devin-ai-integration[bot] wants to merge 6 commits into
Open
feat: Implement Spring Cache for Account Service Transaction Retrieval#3devin-ai-integration[bot] wants to merge 6 commits into
devin-ai-integration[bot] wants to merge 6 commits into
Conversation
- Add spring-boot-starter-cache dependency to Account Service - Enable @EnableCaching in AccountServiceApplication - Add @Cacheable annotation to getTransactionsFromAccountId method - Configure Caffeine cache with 5-minute TTL and 1000 entry limit - Cache key uses accountId for proper isolation per account This implementation reduces unnecessary inter-service calls between Account Service and Transaction Service, improving response times for transaction history requests. Co-Authored-By: Sam Fertig <sam.fertig@codeium.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
- Add CachePerformanceTest.java for unit testing cache performance - Add application-test.yml with test-specific cache configuration - Add test-cache-performance.sh script for HTTP endpoint testing - These tools will help measure >90% performance improvement target Co-Authored-By: Sam Fertig <sam.fertig@codeium.com>
- Add H2 database dependency for testing - Configure proper test database and cache settings - Add mock setup for TransactionService with simulated delay - Fix test method to properly measure cache performance - Test now simulates 100ms external service delay to demonstrate cache benefits Co-Authored-By: Sam Fertig <sam.fertig@codeium.com>
Co-Authored-By: Sam Fertig <sam.fertig@codeium.com>
Co-Authored-By: Sam Fertig <sam.fertig@codeium.com>
- Add url parameter to @FeignClient annotation for direct service connection - Update application.yml with Feign client URL configuration - Enable successful cache testing with mock Transaction Service Co-Authored-By: Sam Fertig <sam.fertig@codeium.com>
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.
Implement Response Cache for Account Transactions
Summary
This PR implements Spring Cache with Caffeine provider to cache transaction responses in the Account Service, reducing unnecessary calls to the Transaction Service and improving UI response times. The implementation adds
@Cacheableannotation to thegetTransactionsFromAccountIdmethod with account-specific cache keys.Key Changes:
@EnableCachingin main application class@Cacheable(value = "transactions", key = "#accountId")to transaction retrieval methodPerformance Results from Browser Testing:
Review & Testing Checklist for Human
Recommended Test Plan:
/accounts/{accountId}/transactionsfor the same accountDiagram
%%{ init : { "theme" : "default" }}%% graph TD Controller["AccountController<br/>/accounts/{id}/transactions"] Service["AccountServiceImpl<br/>getTransactionsFromAccountId()"] Cache["Caffeine Cache<br/>key: accountId<br/>TTL: 5min"] FeignClient["TransactionService<br/>@FeignClient"] ExternalService["Transaction-Service<br/>(External Microservice)"] Controller --> Service Service --> Cache Cache -->|cache miss| FeignClient Cache -->|cache hit| Service FeignClient --> ExternalService %% Styling classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFF class Service,Cache,FeignClient major-edit class Controller context class ExternalService context subgraph Legend L1[Major Edit]:::major-edit L2[Minor Edit]:::minor-edit L3[Context/No Edit]:::context endNotes
Configuration Details:
maximumSize=1000,expireAfterWrite=5maccountIdparameter for isolationTesting Environment:
Link to Devin run: https://app.devin.ai/sessions/53d151527f2944108c41dd9f386a5e58
Requested by: Sam Fertig (@samfert-codeium)