Package io.jmix.core
Class CacheOperations
java.lang.Object
io.jmix.core.CacheOperations
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
-
Method Summary
Modifier and TypeMethodDescription<K,
V> void forEach
(org.springframework.cache.Cache cache, BiConsumer<K, V> consumer) <K,
V> V Used as safe alternative forCache.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 defaultConcurrentMapCache
.
-
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 defaultConcurrentMapCache
.- Parameters:
cache
-- Returns:
- true if supported
-
forEach
-
getKeys
- Parameters:
cache
- - cache- Returns:
- a set view of the keys contained in this cache
-
getValues
- 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 forCache.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 becauseorg.springframework.cache.jcache.JCacheCache#ValueLoaderEntryProcessor
is not serializable.- Type Parameters:
K
- key typeV
- value type- Parameters:
cache
- to get value fromkey
- to get value byvalueLoader
- to load value in case of absence in cache- Returns:
- cached value
-