Package io.jmix.core

Class CacheOperations

java.lang.Object
io.jmix.core.CacheOperations

@Component("core_CacheOperations") public class CacheOperations extends Object
Used for additional cache operation like iterations over cache entries. Spring cache API doesn't support some operations over cache (e.g. iterations), so the CacheOperations facade uses specific API of cache implementations.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    <K, V> void
    forEach(org.springframework.cache.Cache cache, BiConsumer<K,V> consumer)
     
    <K, V> V
    get(org.springframework.cache.Cache cache, K key, Callable<V> valueLoader)
    Used as safe alternative for Cache.get(java.lang.Object, java.util.concurrent.Callable)
    <K> Set<K>
    getKeys(org.springframework.cache.Cache cache)
     
    <V> Collection<V>
    getValues(org.springframework.cache.Cache cache)
     
    boolean
    isIterableCache(org.springframework.cache.Cache cache)
    Iterations over cache entries are supported for JCache and default ConcurrentMapCache.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CacheOperations

      public CacheOperations()
  • Method Details

    • isIterableCache

      public boolean isIterableCache(org.springframework.cache.Cache cache)
      Iterations over cache entries are supported for JCache and default ConcurrentMapCache.
      Parameters:
      cache -
      Returns:
      true if supported
    • forEach

      public <K, V> void forEach(org.springframework.cache.Cache cache, BiConsumer<K,V> consumer)
    • getKeys

      public <K> Set<K> getKeys(org.springframework.cache.Cache cache)
      Parameters:
      cache - - cache
      Returns:
      a set view of the keys contained in this cache
    • getValues

      public <V> Collection<V> getValues(org.springframework.cache.Cache cache)
      Parameters:
      cache - - cache
      Returns:
      a collection of the values contained in this cache
    • get

      @Nullable public <K, V> V get(org.springframework.cache.Cache cache, K key, Callable<V> valueLoader)
      Used as safe alternative for Cache.get(java.lang.Object, java.util.concurrent.Callable)

      WARNING: do not use Cache#get(java.lang.Object, java.util.concurrent.Callable) with Hazelcast. It causes NotSerializableException because org.springframework.cache.jcache.JCacheCache#ValueLoaderEntryProcessor is not serializable.
      Type Parameters:
      K - key type
      V - value type
      Parameters:
      cache - to get value from
      key - to get value by
      valueLoader - to load value in case of absence in cache
      Returns:
      cached value