Class DefaultLoadBalancerCache
- java.lang.Object
-
- org.springframework.cache.support.AbstractValueAdaptingCache
-
- org.springframework.cloud.loadbalancer.cache.DefaultLoadBalancerCache
-
- All Implemented Interfaces:
org.springframework.cache.Cache
public class DefaultLoadBalancerCache extends org.springframework.cache.support.AbstractValueAdaptingCache
A defaultCache
implementation used by Spring Cloud LoadBalancer. The current implementation usesConcurrentMapWithTimedEviction
underneath. Based onConcurrentMapCache
.- Since:
- 2.2.0
- Author:
- Olga Maciaszek-Sharma
- See Also:
- Evictor,
ConcurrentMapWithTimedEviction
,ConcurrentMapCache
-
-
Constructor Summary
Constructors Constructor Description DefaultLoadBalancerCache(String name)
Create a new DefaultCache with the specified name.DefaultLoadBalancerCache(String name, boolean allowNullValues)
Create a new EvictorCache with the specified name.DefaultLoadBalancerCache(String name, long evictMs, boolean allowNullValues)
Create a new DefaultCache with the specified name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
void
evict(Object key)
boolean
evictIfPresent(Object key)
<T> T
get(Object key, Callable<T> valueLoader)
String
getName()
ConcurrentMap<Object,Object>
getNativeCache()
boolean
invalidate()
protected Object
lookup(Object key)
void
put(Object key, Object value)
void
put(Object key, Object value, long evictMs)
org.springframework.cache.Cache.ValueWrapper
putIfAbsent(Object key, Object value)
org.springframework.cache.Cache.ValueWrapper
putIfAbsent(Object key, Object value, long evictMs)
-
-
-
Constructor Detail
-
DefaultLoadBalancerCache
public DefaultLoadBalancerCache(String name)
Create a new DefaultCache with the specified name.- Parameters:
name
- the name of the cache
-
DefaultLoadBalancerCache
public DefaultLoadBalancerCache(String name, long evictMs, boolean allowNullValues)
Create a new DefaultCache with the specified name.- Parameters:
name
- the name of the cacheevictMs
- default time to evict the entriesConcurrentMapWithTimedEviction
allowNullValues
- whether to accept and convertnull
values for this cache
-
DefaultLoadBalancerCache
public DefaultLoadBalancerCache(String name, boolean allowNullValues)
Create a new EvictorCache with the specified name.- Parameters:
name
- the name of the cacheallowNullValues
- whether to accept and convertnull
values for this cache
-
-
Method Detail
-
lookup
protected Object lookup(Object key)
- Specified by:
lookup
in classorg.springframework.cache.support.AbstractValueAdaptingCache
-
getName
public String getName()
-
getNativeCache
public ConcurrentMap<Object,Object> getNativeCache()
-
putIfAbsent
@Nullable public org.springframework.cache.Cache.ValueWrapper putIfAbsent(Object key, @Nullable Object value)
-
putIfAbsent
@Nullable public org.springframework.cache.Cache.ValueWrapper putIfAbsent(Object key, @Nullable Object value, long evictMs)
-
evict
public void evict(Object key)
-
evictIfPresent
public boolean evictIfPresent(Object key)
-
clear
public void clear()
-
invalidate
public boolean invalidate()
-
-