Implement caching using Spring Caching and Caffeine for local and Redis for distributed (SZ-5)
rk@tigase.net opened 2 hours ago

Implement Caching with Spring Caching (Caffeine + Redis)

Goal:
Introduce caching to improve performance and reduce database load. Use Caffeine for local development and Redis for distributed environments.

Estimated Time: 4–6 hours


Task Breakdown

1. Add Spring Caching Support

  •  Add spring-boot-starter-cache to pom.xml
  •  Enable caching via @EnableCaching in the config class

2. Configure Local Caffeine Cache

  •  Add Caffeine dependency
  •  Configure cache spec via application.yml
  •  Test cache hit/miss behavior for selected methods

3. Configure Redis for Distributed Caching

  •  Add Redis dependencies (spring-boot-starter-data-redis)
  •  Use profile-based configuration to switch between local and Redis
  •  Configure Redis connection via application-prod.yml or env

4. Apply Caching to Key Methods

  •  Annotate service-layer methods with @Cacheable, @CacheEvict
    • Example: getUserById, getProjectById, searchIssues
  •  Define sensible cache names and TTLs
  •  Add conditional caching if needed

5. Validate Caching Behavior

  •  Write integration tests to verify caching
    • Check initial call vs repeat call
  •  Confirm that Redis keys are being stored correctly (when in prod profile)

🕒 Estimated Time: 4–6 hours

Subtask Estimates

TaskEstimated Time
Add and configure Spring Cache + Caffeine~1.5 hours
Redis integration and profile switch~1.5 hours
Apply annotations and optimize cache usage~1 hour
Test and validate cache behavior (local + Redis)~1 hour

Output Artifacts

  • Local cache: Caffeine via @Cacheable
  • Prod cache: Redis via profile-based config
  • Configurable TTLs and cache regions
  • Verified caching behavior in integration tests
issue 1 of 1
Type
New Feature
Priority
Normal
Assignee
Version
none
Sprints
n/a
Customer
n/a
Issue Votes (0)
Watchers (3)
Reference
SZ-5
Please wait...
Page is in error, reload to recover