You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
Enable Caching in Spring Boot:
Add @EnableCaching to your main application class.
Annotate Service Methods:
Use the @Cacheable annotation on methods like getStockPrice:
Configure a Cache Manager:
In your configuration, define a simple cache manager (e.g., ConcurrentMapCacheManager) or integrate with a distributed cache like Redis.
Test the Cache Behavior:
Ensure that repeated calls within the cache expiry time do not trigger new API requests.
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.
Add
@EnableCachingto your main application class.Use the
@Cacheableannotation on methods likegetStockPrice:In your configuration, define a simple cache manager (e.g., ConcurrentMapCacheManager) or integrate with a distributed cache like Redis.
Ensure that repeated calls within the cache expiry time do not trigger new API requests.