Class 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 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 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 Detail

      • lookup

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

        public String getName()
      • get

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

        public void put​(Object key,
                        @Nullable
                        Object value,
                        long evictMs)
      • 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)
      • 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()