|
Ok, I think I finally got it  Essentially you have two clients / two use cases using the same Hibernate instance, and in some use cases reading stale data is acceptable, in others its not.
Makes me thing if you actually wouldn't better served by the capability of having a 2LC enabled which is disabled by default - so that all reads go to the database unless specifically instructed on a per-use case enablement?
That would get the normal Hibernate use cases avoid hitting stale data but still correctly invalidate the caches as needed, or even help pre-populate them.
Today you can disable 2LC on a specific Session. If you can edit the code of the sites using just Hibernate you could enable this option on each session open. Maybe the Session open construct is centralized, that would certainly make it an easy experiment? You'd then enable it for the Hibernate Search use case, and there you use the SECOND_LEVEL_CACHE load option.
|