Class SpringCache2kCache

  • All Implemented Interfaces:
    org.springframework.cache.Cache

    public class SpringCache2kCache
    extends Object
    implements org.springframework.cache.Cache
    Cache wrapper for the spring cache abstraction.
    Author:
    Jens Wilke
    • Field Detail

      • cache

        protected final org.cache2k.Cache<Object,​Object> cache
    • Constructor Detail

      • SpringCache2kCache

        public SpringCache2kCache​(org.cache2k.Cache<Object,​Object> cache)
        Create an adapter instance for the given cache2k instance.
        Parameters:
        cache - the cache2k cache instance to adapt values for this cache
    • Method Detail

      • getName

        public String getName()
        Specified by:
        getName in interface org.springframework.cache.Cache
      • getNativeCache

        public org.cache2k.Cache<Object,​Object> getNativeCache()
        Specified by:
        getNativeCache in interface org.springframework.cache.Cache
      • get

        @Nullable
        public @Nullable org.springframework.cache.Cache.ValueWrapper get​(Object key)
        Get value from the cache, may invoke the loader if one is specified. the get() method is used by Spring if the sync parameter is not set.
        Specified by:
        get in interface org.springframework.cache.Cache
      • get

        public <T> T get​(Object key,
                         @Nullable
                         @Nullable Class<T> type)
        Specified by:
        get in interface org.springframework.cache.Cache
      • put

        public void put​(Object key,
                        Object value)
        Specified by:
        put in interface org.springframework.cache.Cache
      • putIfAbsent

        public org.springframework.cache.Cache.ValueWrapper putIfAbsent​(Object key,
                                                                        Object value)
        Specified by:
        putIfAbsent in interface org.springframework.cache.Cache
      • evict

        public void evict​(Object key)
        May work async.
        Specified by:
        evict in interface org.springframework.cache.Cache
      • clear

        public void clear()
        May work async.
        Specified by:
        clear in interface org.springframework.cache.Cache
      • evictIfPresent

        public boolean evictIfPresent​(Object key)
        Returns when evicted.
        Specified by:
        evictIfPresent in interface org.springframework.cache.Cache
      • invalidate

        public boolean invalidate()
        Like clear, but returns when everything is cleared.
        Specified by:
        invalidate in interface org.springframework.cache.Cache
      • isLoaderPresent

        public boolean isLoaderPresent()