I would use a second-level cache for the entity, query for all the subsidiry's entities at startup (this will fill the second-level cache), and initialize an application cache which would just map externalId, subsidiaryId to id.
I would use a second-level cache for the entity, query for all the subsidiry's entities at startup (this will fill the second-level cache), and initialize an application cache which would just map externalId, subsidiaryId to id. Then, each time you're searching for an entity with a given externalId, subsidiaryId, first get its ID from the application cache, then if the ID is not in the cache, execute the query, update the application cache, and return the found entity if the ID is in the cache, get the entity using its ID, which will go to the second-level cache and avoid hitting the DB.
Thanks for your comment. Your suggested course of action entails the cache maintenance, right? Since my multi-threaded app adds these entities as it goes along.
The advantages of using the ORM's facade for cache for me was so that I don't need to enter additional handling for these cases. If this is the only option I have I'm thinking maybe I'm better off with the query cache. I'd love to hear if you think there is a different way within the ORM facede to do this.
– Ittai Nov 23 at 6:10 I don't think there is a different way. The query cache can only be populated by executing queries, and these queries will first go to the database if the're not cached yet. – JB Nizet Nov 23 at 7:42 Yeah, I know there isn't a different way with respect to the query cache itself, I was hoping for a different way with respect to the entity cache.
Something like defining for it to also look for the externalId, subsidiaryId pair when it misses on the id before going to the db. – Ittai Nov 23 at 9:00.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.