Package fun.awooo.dive.cache.common
Interface CommonCache<K,V>
-
- Type Parameters:
K- 键的类型V- 值的类型
- All Known Subinterfaces:
PersistCache<K,V>,TimeCache<K,V>
public interface CommonCache<K,V>一个用于缓存键值对数据的对象
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidclear()清除所有键值对default Vcompute(K key, java.util.function.BiFunction<? super K,? super V,? extends V> remapping)重新映射一个default VcomputeIfAbsent(K key, java.util.function.Function<? super K,? extends V> mapping)获取或映射一个default VcomputeIfPresent(K key, java.util.function.BiFunction<? super K,? super V,? extends V> remapping)若存在则重新映射一个Vdelete(K key)删除对应键值对Vget(K key)获取键对应的值default Vget(K key, java.util.function.Supplier<V> supplier)获取或生成default VgetOrDefault(K key, V defaultValue)获取对应值,若无则返回默认值booleanhas(K key)是否存在某个键default Vmerge(K key, V value, java.util.function.BiFunction<? super V,? super V,? extends V> remapping)合并计算default VputIfAbsent(K key, V value)若不存在则存入voidremove(K key)移除对应键值对voidset(K key, V value)新增或更新一个键值对
-
-
-
Method Detail
-
has
boolean has(K key)
是否存在某个键- Parameters:
key- 键- Returns:
- 存在返回 true, 不存在返回 false
-
remove
void remove(K key)
移除对应键值对- Parameters:
key- 键
-
clear
void clear()
清除所有键值对
-
getOrDefault
default V getOrDefault(K key, V defaultValue)
获取对应值,若无则返回默认值- Parameters:
key- keydefaultValue- 默认值- Returns:
- 值
-
get
default V get(K key, java.util.function.Supplier<V> supplier)
获取或生成- Parameters:
key- 键supplier- 生产者- Returns:
- 值
-
computeIfAbsent
default V computeIfAbsent(K key, java.util.function.Function<? super K,? extends V> mapping)
获取或映射一个- Parameters:
key- 键mapping- 映射- Returns:
- 值
-
computeIfPresent
default V computeIfPresent(K key, java.util.function.BiFunction<? super K,? super V,? extends V> remapping)
若存在则重新映射一个- Parameters:
key- 键remapping- 重新映射- Returns:
- 值
-
compute
default V compute(K key, java.util.function.BiFunction<? super K,? super V,? extends V> remapping)
重新映射一个- Parameters:
key- 键remapping- 重新映射- Returns:
- 值
-
-