public class TransactionAwareCacheDecorator
extends java.lang.Object
implements org.springframework.cache.Cache
put(java.lang.Object, java.lang.Object)
, evict(java.lang.Object)
and clear()
operations with Spring-managed transactions (through Spring's TransactionSynchronizationManager
,
performing the actual cache put/evict/clear operation only in the after-commit phase of a
successful transaction. If no transaction is active, put(java.lang.Object, java.lang.Object)
, evict(java.lang.Object)
and
clear()
operations will be performed immediately, as usual.
Use of more aggressive operations such as putIfAbsent(java.lang.Object, java.lang.Object)
cannot be deferred
to the after-commit phase of a running transaction. Use these with care.
TransactionAwareCacheManagerProxy
Constructor and Description |
---|
TransactionAwareCacheDecorator(org.springframework.cache.Cache targetCache)
Create a new TransactionAwareCache for the given target Cache.
|
Modifier and Type | Method and Description |
---|---|
void |
clear() |
void |
evict(java.lang.Object key) |
org.springframework.cache.Cache.ValueWrapper |
get(java.lang.Object key) |
<T> T |
get(java.lang.Object key,
java.util.concurrent.Callable<T> valueLoader) |
<T> T |
get(java.lang.Object key,
java.lang.Class<T> type) |
java.lang.String |
getName() |
java.lang.Object |
getNativeCache() |
org.springframework.cache.Cache |
getTargetCache()
Return the target Cache that this Cache should delegate to.
|
void |
put(java.lang.Object key,
java.lang.Object value) |
org.springframework.cache.Cache.ValueWrapper |
putIfAbsent(java.lang.Object key,
java.lang.Object value) |
public TransactionAwareCacheDecorator(org.springframework.cache.Cache targetCache)
targetCache
- the target Cache to decoratepublic org.springframework.cache.Cache getTargetCache()
public java.lang.String getName()
getName
in interface org.springframework.cache.Cache
public java.lang.Object getNativeCache()
getNativeCache
in interface org.springframework.cache.Cache
@Nullable public org.springframework.cache.Cache.ValueWrapper get(java.lang.Object key)
get
in interface org.springframework.cache.Cache
public <T> T get(java.lang.Object key, @Nullable java.lang.Class<T> type)
get
in interface org.springframework.cache.Cache
@Nullable public <T> T get(java.lang.Object key, java.util.concurrent.Callable<T> valueLoader)
get
in interface org.springframework.cache.Cache
public void put(java.lang.Object key, @Nullable java.lang.Object value)
put
in interface org.springframework.cache.Cache
@Nullable public org.springframework.cache.Cache.ValueWrapper putIfAbsent(java.lang.Object key, @Nullable java.lang.Object value)
putIfAbsent
in interface org.springframework.cache.Cache
public void evict(java.lang.Object key)
evict
in interface org.springframework.cache.Cache
public void clear()
clear
in interface org.springframework.cache.Cache