Small Spring Boot demo app demonstrating how to use Spring Cache when integrating with slow external services.
- There are two slow services, 1.
SlowExternalUserService
and 2.SuperSlowExternalService
ScheduledCacheTask
is responsible for initiating theUsers
cache at startup and refreshing the cache every 120 seconds (by using@Scheduled(fixedDelay)
). This is done by calling the slow services and response is rewritten in theUsers
cache (by using@CachePut
)UserResource
(REST API) is retrieving the data fromUserService
, which reads cached data by using theCacheManager
- It takes about 10 seconds after startup before data from
SlowExternalUserService
is available and 20 seconds fromSuperSlowExternalService
$ ./mvnw spring-boot:run
- GET http://localhost:8080/users/{systemName}/{appName}/{env} - return users from
Users
cache- systemName=
system1, system2
- appName=
app11, app12, app13, app21
- env=
PROD, TEST
- systemName=
- GET http://localhost:8080/cache/refresh/{systemName}/{appName}/{env} - triggers refresh of
Users
cache- systemName=
system1, system2
- appName=
app11, app12, app13, app21
- env=
PROD, TEST
- systemName=