Package cn.sliew.milky.cache.caffeine
Class CaffeineCache<K,V>
- java.lang.Object
-
- cn.sliew.milky.cache.caffeine.CaffeineCache<K,V>
-
- All Implemented Interfaces:
Cache<K,V>
public class CaffeineCache<K,V> extends Object implements Cache<K,V>
refresh > expire ensure hot key would refreshed before expired. cache key would not be refreshed when no request comes.because maximumSize can't be combined with maximumWeight, CaffeineCache would not support maximumWeight parameter.
-
-
Constructor Summary
Constructors Constructor Description CaffeineCache(CaffeineCacheOptions<K,V> options)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()VcomputeIfAbsent(K key, CacheLoader<K,V> loader, Duration expire)booleancontainsKey(K key)voiddestroy()Vget(K key)Iterator<K>hotKeyIterator(int n)Iterator<K>keyIterator()Stringname()voidput(K key, V value)voidput(K key, V value, Duration expire)voidremove(K key)voidremoveAll(Iterable<K> keys)longsize()voidstats(io.micrometer.core.instrument.MeterRegistry registry)booleansupportNullKey()booleansupportNullValue()
-
-
-
Constructor Detail
-
CaffeineCache
public CaffeineCache(CaffeineCacheOptions<K,V> options)
-
-
Method Detail
-
containsKey
public boolean containsKey(K key)
- Specified by:
containsKeyin interfaceCache<K,V>
-
computeIfAbsent
public V computeIfAbsent(K key, CacheLoader<K,V> loader, Duration expire)
- Specified by:
computeIfAbsentin interfaceCache<K,V>
-
supportNullKey
public boolean supportNullKey()
- Specified by:
supportNullKeyin interfaceCache<K,V>
-
supportNullValue
public boolean supportNullValue()
- Specified by:
supportNullValuein interfaceCache<K,V>
-
hotKeyIterator
public Iterator<K> hotKeyIterator(int n)
- Specified by:
hotKeyIteratorin interfaceCache<K,V>
-
stats
public void stats(io.micrometer.core.instrument.MeterRegistry registry)
-
-