Use-case: My spring application reads data from a DB, but accesses the cache for the same which is pre-loaded. Although rarely, these tables might undergo changes. On such an event, the cached needs to be invalidated and pre-loaded. Also not that the application only reads the data.
After a bit of research, I have found two options..
Option 1: Database trigger to call Spring task.
I would need to configure triggers on insert/update of each of the tables which should call the spring @Scheduled task. This would take care of refreshing the cache. But then how do I call the Spring's @Scheduled task on a databse trigger?
Option 2: Using Oracle's DatabaseChangeNotification
I would have to register a listener with the Oracle DB. This would listen to all changes and my application would be notified whenever there is a change. But then how do I do this using Spring?
Which is the better option? Is there a better option available? Also any help in proceeding further on the options?
Note: I am using Spring + JPA + Oracle 10g