Rollbacking Spring 3.1 Cache or Evict
I have a question regarding the caching with Spring 3.1 : is that possible to configure Spring to automaticly rollback the cache modifications when JDBC rollback occurs…
I'm talking here of consistenc开发者_运维知识库y between the cache and the DB.
If an exception occurs in the method where the caching is declared, there is nothing to cache, everything is fine.
There is no easy way to bound the Spring cache to the transaction, and I think that it would not be ok to do so.
Try using something like Hibernate 2nd level Cache (e.g. with Ehcache) or a similar DB Cache. They automatically remove or add the data depending on the state of the DB. They assure the consistency with the DB.
精彩评论