Skip to content

[feat]: Implement Caching for API Responses #8

@0PrashantYadav0

Description

@0PrashantYadav0

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:
      @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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions