I have a database, it can be changed by hand (via php admin), and maybe through my java application. In java, jpo cache is provided, but it is possible that a situation will change when the object changes in both RayTime and DB, because someone has changed it through the admin area. Yes, I am according to certain rules to the merdzhu objects, but what to do with those threads that have already taken the object (invalid) and work with it? After all, their behavior will already be wrong, because the object has changed.

  • "what to do with those threads that have already taken an object to themselves (invalid) and work with it?" - do not take objects to run business logic from the cache, always take from the database, do not keep them in memory. In general, the cache is used only to quickly give a static response to the client. - etki
  • There are hazelcast types that synchronize objects in memory (almost) in real time. Or use transactions at the database level and do not use the cache. - rustyx
  • How then without a cache will objects work in multiple threads? After all, then each of the threads will have its own object. Example, we take data from DB in two streams (two different connections to the service) and both streams reach the tuple and form an object based on the data and then change it and commit it in DB. If there is no cache, then the changes will be jammed, because each of the threads will have its own object, how then does it work multithreaded? - GermanSevostyanov

0