iiitl / iiitl/Stoxs

[feat]: Implement Caching for API Responses

Open
#8 0 comments 0 reactions 0 assignees View on GitHub
feature java medium spring-boot
Dominant language
TypeScript
Stars
1
Forks
1
PR merge metrics
No merged PRs in 30d

Description

## Description

- **Detailed Description:**
Repeated external API calls to Finnhub can lead to performance bottlenecks and trigger rate limiting. Caching the responses for a short period can significantly improve performance and reduce external API usage.
- **How to Solve:**
1. **Enable Caching in Spring Boot:**
Add `@EnableCaching` to your main application class.
2. **Annotate Service Methods:**
Use the `@Cacheable` annotation on methods like `getStockPrice`:
```java
@Cacheable("stockPrice")
public String getStockPrice(String symbol) {
// existing code
}
```
3. **Configure a Cache Manager:**
In your configuration, define a simple cache manager (e.g., ConcurrentMapCacheManager) or integrate with a distributed cache like Redis.
4. **Test the Cache Behavior:**
Ensure that repeated calls within the cache expiry time do not trigger new API requests.

Contributor guide

No contributing guide indexed for this repository

Research direction

Locate the main Spring Boot application class, the service method named getStockPrice, and the existing configuration and tests. Read how Finnhub API requests are made, then verify that repeated calls within the chosen cache period do not make new API requests.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring-boot
Domain
api, backend, performance
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.