say I have an EntityManager that can read(PK)
a dataset from the DB and return it.
I have an application that will process multiple records, iterate over them and for each, use the EntityManager to read each record.
Therefore it would be nice to inform that EntityManager about the coming workload so it is able to preload the necessary data more efficiently.
How would you integrate such optional hints into a clean, SoC OO-Design?
Thanks alot
2
I think it’s not responsibility of EntityManager (ActiveRecord object I guess) to care about workload.
Add another object, which will preload entities to the cache storage in case of coming workload, then add class EntityManagerCached which will override method read() to check cache storage first and then read from DB.
Words like “manager” in the class name is a warning sign.
1