0

I have added the cache changes in CREATE(@cacheable) and PUT(@CachePut) which is working as expected in Java Spring Boot.

One case which is creating an issue is that I am not able to refresh the cache after every few minutes or on an hourly basis or weekly basis. This needs to be done because suppose new value is added from different source like different application. Then in that case I need to reload the cache. Please suggest.

andrewJames
  • 19,570
  • 8
  • 19
  • 51
  • 1
    Does this answer your question? [Can I set a TTL for @Cacheable](https://stackoverflow.com/questions/8181768/can-i-set-a-ttl-for-cacheable) – Alberto Sinigaglia Jun 14 '21 at 14:40
  • Having data managed in a cache, while also allowing the underlying data store to be updated via other routes (ones which bypass the cache) is going to lead to data inconsistencies (and probably also to data loss), regardless of your approach to cache reloading. – andrewJames Jun 14 '21 at 14:54
  • @AlbertoSinigaglia If i have particular id (1001) data in cache and also If i'm directly updating that id (1001) data in DB. So when i will do GET call i'll get cache's data in response not the updated DB's data. So my question is how can i refresh/reload the cache after few minutes ? Because if i'll use cache, i'll get actual data either if i do put call(Cache evict or cachePut) from service which will update cache or if i'll restart my service. – Aruna Dang Jun 14 '21 at 16:45

0 Answers0