Skip to content

Update cache data

Piyush Chaudhari edited this page Sep 13, 2018 · 3 revisions

To update cache data we use REST API CountryController.java create new record on database as below.

URL: http://localhost:8080/v1/country/create
Method: POST
Request: { "name":"Fiji" }

Response: { "country": { "id": 6, "name": "Fiji" } }


To update cache data we use REST API CachingController.java as below,

URL: http://localhost:8080/v1/caching/clear/{name} where {name} is replace by caching name e.g countryListCache configured on CountryServiceImpl.java with @Cacheable("countryListCache")
Method: GET

Response: {"cachingUpdate":true}


Fetch data from cache we need to use below REST API CountryController.java as below.

URL: http://localhost:8080/v1/country/list
Method: GET

Response: { "countryList":[ { "id":1, "name":"Australia" }, { "id":2, "name":"Brazil" }, { "id":3, "name":"Canada" }, { "id":4, "name":"Denmark" }, { "id":5, "name":"Egypt" }, { "id":6, "name":"Fiji" } ] }

Clone this wiki locally