I have an application in spring boot that handles custom requests. And there exists a scheduled job running every 30 sec and it fetches a list of objects from db and performs certain operations. I get freaked out thinking that I need to query the database for every 30 seconds, and instead I could keep these objects in a data structure. There are rest APIs that adds or deletes or edits the properties of these objects and therefore, I would need to handle update of these objects In the data structure as well. Which approach should I go for ?
The size of the objects can be anything between 100 - 10000. I use Postgres as my db.