Spring 在事务提交后,如何才能执行“@cacheexecute”或“@CachePut”?
为什么SpringSpring 在事务提交后,如何才能执行“@cacheexecute”或“@CachePut”?,spring,caching,Spring,Caching,为什么Spring@cacheexecute和@CachePut在事务提交后不调用; 我认为这样,我们可以避免一些错误。例如,在逐出缓存和事务提交之间,调用一个@Cacheable调用,那么缓存中的值就是脏数据。 我看到了CacheInterceptor,但它看起来好像我无法重写它。有人可以告诉我,在事务提交后,我如何才能@cacheexecute或@CachePut?如果CacheManage扩展为AbstractTransactionSupportingCacheManager,您可以调用S
@cacheexecute
和@CachePut
在事务提交后不调用;
我认为这样,我们可以避免一些错误。例如,在逐出缓存和事务提交之间,调用一个@Cacheable
调用,那么缓存中的值就是脏数据。
我看到了
CacheInterceptor
,但它看起来好像我无法重写它。有人可以告诉我,在事务提交后,我如何才能@cacheexecute
或@CachePut
?如果CacheManage
扩展为AbstractTransactionSupportingCacheManager
,您可以调用SetTransactionware(true)
,然后在事务提交后@Cache调用 如果CacheManage
扩展为AbstractTransactionSupportingCacheManager
,您可以调用SetTransactionWare(true)
,然后在事务提交后@Cache invoke