I have no real hibernate or ibatis (or any real ORM experience), but I am starting to learn ibatis. I have a general question on ORM caching. My assumption is that the objects are cached in java memory. So...in a typical environment (multiple app servers, one database) how do you clear cache across all app servers programatically?
2 app servers, serverA and serverB
one object is cached on serverA...we'll call it InventoryList (list of available inventory)
serverA gets a call to updateInventory service which clears cache of InventoryList object on serverA
doesn't serverB still have the cached old object still there (not purged)?
You ideally would want to cluster the two app servers. Other option would be to retrieve the object from the db every time you do some operation so you are ensured the data is fresh.
Joined: Oct 14, 2004
>>You ideally would want to cluster the two app servers.
I do not understand how that helps. Presumably the cached objects are stored in JVM memory which would not be shared in a cluster (correct me if I'm wrong...but I don't see how it could).
>>Other option would be to retrieve the object from the db every time you do some operation so you are ensured the data is fresh.
Doesn't that defeat the point of caching?
The idea is there is memory to memory replication between the clusters. This has efficiency issues of it's own and my or may not be worth the cost.
There are different levels of ORM caching. You can cache within a user transaction without any problem since transactions guarantee that data hasn't changed out from under you. For higher level caching, you can look at data patterns. Is anything known about your data? Maybe some data that is essentially read only and you can cache for a certain amount of time. For example, the list of 50 states.