- Type Parameters:
K- Key type.V- Value type.
public interface CacheAccessor<K,V>
Interface defining access to the client-side cache. The cache must support value retrieval, value update (for Redis Cache
read-through so values obtained from Redis get written into the client-side cache) and removal (used for invalidations).
- Since:
- 6.0
- Author:
- Mark Paluch
-
Method Summary
Modifier and Type Method Description voidevict(K key)Evict the mapping for this key from this cache if it is present.static <K, V> CacheAccessor<K,V>forMap(Map<K,V> map)Obtain aCacheAccessorfor a cache object implementingMap.Vget(K key)Return the value to which this cache maps the specified key.voidput(K key, V value)Associate the specified value with the specified key in this cache.
-
Method Details
-
forMap
Obtain aCacheAccessorfor a cache object implementingMap.- Type Parameters:
K- Key type.V- Value type.- Parameters:
map- the cache.- Returns:
- a
CacheAccessorbacked by aMapimplementation.
-
get
Return the value to which this cache maps the specified key.Note: This method does not allow for differentiating between a cached
nullvalue and no cache entry found at all.- Parameters:
key- the key whose associated value is to be returned.- Returns:
- the value to which this cache maps the specified key (which may be
nullitself), or alsonullif the cache contains no mapping for this key.
-
put
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.
- Parameters:
key- the key with which the specified value is to be associated.value- the value to be associated with the specified key.
-
evict
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.
- Parameters:
key- the key whose mapping is to be removed from the cache.
-