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 default Cache implementation used by Spring Cloud LoadBalancer. The current implementation uses ConcurrentMapWithTimedEviction underneath. Based on ConcurrentMapCache.
Since:
2.2.0
Author:
Olga Maciaszek-Sharma
See Also:
  • Evictor
  • ConcurrentMapWithTimedEviction
  • ConcurrentMapCache
  • Constructor Details

    • 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 cache
      evictMs - default time to evict the entries ConcurrentMapWithTimedEviction
      allowNullValues - whether to accept and convert null 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 cache
      allowNullValues - whether to accept and convert null values for this cache
  • Method Details

    • lookup

      protected Object lookup(Object key)
      Specified by:
      lookup in class org.springframework.cache.support.AbstractValueAdaptingCache
    • getName

      public String getName()
    • getNativeCache

      public ConcurrentMap<Object,Object> getNativeCache()
    • get

      public <T> @Nullable T get(Object key, Callable<T> valueLoader)
    • put

      public void put(Object key, @Nullable Object value, long evictMs)
    • putIfAbsent

      public @Nullable org.springframework.cache.Cache.ValueWrapper putIfAbsent(Object key, @Nullable Object value)
    • putIfAbsent

      public @Nullable org.springframework.cache.Cache.ValueWrapper putIfAbsent(Object key, @Nullable Object value, long evictMs)
    • put

      public void put(Object key, @Nullable Object value)
    • evict

      public void evict(Object key)
    • evictIfPresent

      public boolean evictIfPresent(Object key)
    • clear

      public void clear()
    • invalidate

      public boolean invalidate()