put, evict 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, evict and
clear operations will be performed immediately, as usual.Note
Use of immediate operations such as putIfAbsent and
evictIfPresent cannot be deferred to the after-commit phase of a
running transaction. Use these with care in a transactional environment.
TransactionAwareCacheManagerProxy
| Modifier and Type | Field and Description |
|---|---|
| private final Cache |
| Access | Constructor and Description |
|---|---|
| public | TransactionAwareCacheDecorator(Cache
the target Cache to decorate targetCache)Create a new TransactionAwareCache for the given target Cache. |
| Modifier and Type | Method and Description |
|---|---|
| public void | clear()
Implements org. Clear the cache through removing all mappings. |
| public void | evict(final Object
the key whose mapping is to be removed from the cache key)Implements org. Evict the mapping for this key from this cache if it is present. |
| public boolean | evictIfPresent(Object
the key whose mapping is to be removed from the cache key)Overrides default org. Evict the mapping for this key from this cache if it is present, expecting the key to be immediately invisible for subsequent lookups. |
| public Cache. | get(Object
the key whose associated value is to be returned key)Implements org. Return the value to which this cache maps the specified key. |
| public <T> T | get(Object
the key whose associated value is to be returned key, Class<T> the required type of the returned value (may be
type)null to bypass a type check; in case of a null
value found in the cache, the specified type is irrelevant)Implements org. Return the value to which this cache maps the specified key, generically specifying a type that return value will be cast to. |
| public <T> T | get(Object
the key whose associated value is to be returned key, Callable<T> valueLoader)Implements org. Return the value to which this cache maps the specified key, obtaining
that value from |
| public String | |
| public Object | getNativeCache()
Implements org. Return the underlying native cache provider. |
| public Cache | |
| public boolean | invalidate()
Overrides default org. Invalidate the cache through removing all mappings, expecting all entries to be immediately invisible for subsequent lookups. |
| public void | put(final Object
the key with which the specified value is to be associated key, final Object the value to be associated with the specified key value)Implements org. Associate the specified value with the specified key in this cache. |
| public Cache. | putIfAbsent(Object
the key with which the specified value is to be associated key, Object the value to be associated with the specified key value)Overrides default org. Atomically associate the specified value with the specified key in this cache if it is not set already. |
| public CompletableFuture | retrieve(Object
the key whose associated value is to be returned key)Overrides default org. Return the value to which this cache maps the specified key,
wrapped in a |
| public <T> CompletableFuture | retrieve(Object
the key whose associated value is to be returned key, Supplier<CompletableFuture<T>> valueLoader)Overrides default org. Return the value to which this cache maps the specified key, obtaining
that value from |
| targetCache | back to summary |
|---|---|
| private final Cache targetCache | |
| TransactionAwareCacheDecorator | back to summary |
|---|---|
| public TransactionAwareCacheDecorator(Cache targetCache) Create a new TransactionAwareCache for the given target Cache.
| |
| clear | back to summary |
|---|---|
| public void clear() Implements org. Doc from org. Clear the cache through removing all mappings. Actual clearing may be performed in an asynchronous or deferred
fashion, with subsequent lookups possibly still seeing the entries.
This may for example be the case with transactional cache decorators.
Use If the cache is supposed to be compatible with
| |
| evict | back to summary |
|---|---|
| public void evict(final Object key) Implements org. Doc from org. Evict the mapping for this key from this cache if it is present. Actual eviction may be performed in an asynchronous or deferred
fashion, with subsequent lookups possibly still seeing the entry.
This may for example be the case with transactional cache decorators.
Use If the cache is supposed to be compatible with | |
| evictIfPresent | back to summary |
|---|---|
| public boolean evictIfPresent(Object key) Overrides default org. Doc from org. Evict the mapping for this key from this cache if it is present, expecting the key to be immediately invisible for subsequent lookups. The default implementation delegates to | |
| get | back to summary |
|---|---|
| public Cache. Implements org. Doc from org. Return the value to which this cache maps the specified key. Returns
| |
| get | back to summary |
|---|---|
| public <T> T get(Object key, Class<T> type) Implements org. Doc from org. Return the value to which this cache maps the specified key, generically specifying a type that return value will be cast to. Note This variant of
| |
| get | back to summary |
|---|---|
| public <T> T get(Object key, Callable<T> valueLoader) Implements org. Doc from org. Return the value to which this cache maps the specified key, obtaining
that value from If possible, implementations should ensure that the loading operation
is synchronized so that the specified If the | |
| getName | back to summary |
|---|---|
| public String getName() Implements org. Doc from org. Return the cache name.
| |
| getNativeCache | back to summary |
|---|---|
| public Object getNativeCache() Implements org. Doc from org. Return the underlying native cache provider.
| |
| getTargetCache | back to summary |
|---|---|
| public Cache getTargetCache() Return the target Cache that this Cache should delegate to. | |
| invalidate | back to summary |
|---|---|
| public boolean invalidate() Overrides default org. Doc from org. Invalidate the cache through removing all mappings, expecting all entries to be immediately invisible for subsequent lookups.
| |
| put | back to summary |
|---|---|
| public void put(final Object key, final Object value) Implements org. Doc from org. Associate the specified value with the specified key in this cache. If the cache previously contained a mapping for this key, the old value is replaced by the specified value. Actual registration may be performed in an asynchronous or deferred
fashion, with subsequent lookups possibly not seeing the entry yet.
This may for example be the case with transactional cache decorators.
Use If the cache is supposed to be compatible with | |
| putIfAbsent | back to summary |
|---|---|
| public Cache. Overrides default org. Doc from org. Atomically associate the specified value with the specified key in this cache if it is not set already. This is equivalent to:
except that the action is performed atomically. While all out-of-the-box
CacheManager implementations are able to perform the put atomically,
the operation may also be implemented in two steps, e.g. with a check for
presence and a subsequent put, in a non-atomic way. Check the documentation
of the native cache implementation that you are using for more details.
The default implementation delegates to
| |
| retrieve | back to summary |
|---|---|
| public CompletableFuture Overrides default org. Doc from org. Return the value to which this cache maps the specified key,
wrapped in a Can return
| |
| retrieve | back to summary |
|---|---|
| public <T> CompletableFuture Overrides default org. Doc from org. Return the value to which this cache maps the specified key, obtaining
that value from If possible, implementations should ensure that the loading operation
is synchronized so that the specified Null values always indicate a user-level
| |