In my application there are some data which always reads from Seq. I am thinking of having a data structure which would start getting loaded with DB Seq and whenever I need DB Seq, I can directly read from there. Once the data is read from there it needs to be removed so that no one else can read the same data again. Also this data structure would automatically hit DB and get more seq objects once it is left with only 0.25 % of total capacity something like HashMap.
This would enable to not hit DB when I need but directly read from this structure and save DB hit time in my flow.
I am thinking of maintaining a Stack kind of structure but how to reload it automatically because if I use some kind of Scheduler I am not sure how to configure it appropriately.
Any help would be great.