public class TransactionAwareCacheDecorator extends java.lang.Object implements Cache
put(java.lang.Object, java.lang.Object)
and evict(java.lang.Object)
operations with
Spring-managed transactions (through Spring's TransactionSynchronizationManager
,
performing the actual cache put/evict operation only in the after-commit phase of a
successful transaction. If no transaction is active, put(java.lang.Object, java.lang.Object)
and evict(java.lang.Object)
operations will be performed immediately, as usual.TransactionAwareCacheManagerProxy
Cache.ValueWrapper
Modifier and Type | Field and Description |
---|---|
private Cache |
targetCache |
Constructor and Description |
---|
TransactionAwareCacheDecorator(Cache targetCache)
Create a new TransactionAwareCache for the given target Cache.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Remove all mappings from the cache.
|
void |
evict(java.lang.Object key)
Evict the mapping for this key from this cache if it is present.
|
Cache.ValueWrapper |
get(java.lang.Object key)
Return the value to which this cache maps the specified key.
|
java.lang.String |
getName()
Return the cache name.
|
java.lang.Object |
getNativeCache()
Return the the underlying native cache provider.
|
void |
put(java.lang.Object key,
java.lang.Object value)
Associate the specified value with the specified key in this cache.
|
private final Cache targetCache
public TransactionAwareCacheDecorator(Cache targetCache)
targetCache
- the target Cache to decoratepublic java.lang.String getName()
Cache
public java.lang.Object getNativeCache()
Cache
getNativeCache
in interface Cache
public Cache.ValueWrapper get(java.lang.Object key)
Cache
null
if the cache contains no mapping for this key.public void put(java.lang.Object key, java.lang.Object value)
Cache
If the cache previously contained a mapping for this key, the old value is replaced by the specified value.
public void evict(java.lang.Object key)
Cache