public class TransactionAwareCacheManagerProxy extends Object implements org.springframework.cache.CacheManager, org.springframework.beans.factory.InitializingBean
CacheManager
, exposing transaction-aware Cache
objects
which synchronize their Cache.put(java.lang.Object, java.lang.Object)
operations with Spring-managed transactions
(through Spring's TransactionSynchronizationManager
,
performing the actual cache put operation only in the after-commit phase of a successful transaction.
If no transaction is active, Cache.put(java.lang.Object, java.lang.Object)
operations will be performed immediately, as usual.setTargetCacheManager(org.springframework.cache.CacheManager)
,
TransactionAwareCacheDecorator
,
TransactionSynchronizationManager
Constructor and Description |
---|
TransactionAwareCacheManagerProxy()
Create a new TransactionAwareCacheManagerProxy, setting the target CacheManager
through the
setTargetCacheManager(org.springframework.cache.CacheManager) bean property. |
TransactionAwareCacheManagerProxy(org.springframework.cache.CacheManager targetCacheManager)
Create a new TransactionAwareCacheManagerProxy for the given target CacheManager.
|
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
org.springframework.cache.Cache |
getCache(String name) |
Collection<String> |
getCacheNames() |
void |
setTargetCacheManager(org.springframework.cache.CacheManager targetCacheManager)
Set the target CacheManager to proxy.
|
public TransactionAwareCacheManagerProxy()
setTargetCacheManager(org.springframework.cache.CacheManager)
bean property.public TransactionAwareCacheManagerProxy(org.springframework.cache.CacheManager targetCacheManager)
targetCacheManager
- the target CacheManager to proxypublic void setTargetCacheManager(org.springframework.cache.CacheManager targetCacheManager)
public void afterPropertiesSet()
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
@Nullable public org.springframework.cache.Cache getCache(String name)
getCache
in interface org.springframework.cache.CacheManager
public Collection<String> getCacheNames()
getCacheNames
in interface org.springframework.cache.CacheManager