- Type Parameters:
K- Key type.V- Value type.
public interface RedisCache<K,V>
Interface defining common Redis Cache operations.
- Since:
- 6.0
- Author:
- Mark Paluch
-
Method Summary
Modifier and Type Method Description voidaddInvalidationListener(Consumer<? super K> listener)Register a invalidationlistenerthat is notified if a key in this Redis cache expires or gets modified.voidclose()Closes this Redis cache and releases any connections associated with it.Vget(K key)Retrieve avaluefrom Redis for the given cachekey.voidput(K key, V value)Associate the specified value with the specified key in this Redis cache.
-
Method Details
-
get
Retrieve avaluefrom Redis for the given cachekey.- Parameters:
key- the key whose associated value is to be returned.- Returns:
- the value to which this Redis cache value maps the specified key (which may be
nullitself), or alsonullif the Redis cache contains no mapping for this key.
-
put
Associate the specified value with the specified key in this Redis cache.- Parameters:
key- the key with which the specified value is to be associated.value- the value to be associated with the specified key.
-
addInvalidationListener
Register a invalidationlistenerthat is notified if a key in this Redis cache expires or gets modified.- Parameters:
listener- the listener to notify.
-
close
void close()Closes this Redis cache and releases any connections associated with it. If the cache is already closed then invoking this method has no effect.
-