Package fun.awooo.dive.cache.common
Interface TimeCache<K,V>
-
- Type Parameters:
K- 键的类型V- 值的类型
- All Superinterfaces:
CommonCache<K,V>
- All Known Subinterfaces:
PersistCache<K,V>
public interface TimeCache<K,V> extends CommonCache<K,V>
缓存键值对数据, 可以对键值对设置存活时间
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default VcomputeIfAbsent(K key, java.util.function.Function<? super K,? extends V> mapping, long alive)获取或映射一个longexpire(K key)获取对应键的过期时间Vget(K key, long alive)获取键对应的值Vget(K key, long timeout, java.util.concurrent.TimeUnit unit)获取键对应的值Vget(K key, java.time.Instant expire)获取键对应的值default Vget(K key, java.util.function.Supplier<V> supplier, long alive)获取或生成booleanhas(K key, long alive)是否存在某个键booleanhas(K key, long timeout, java.util.concurrent.TimeUnit unit)是否存在某个键booleanhas(K key, java.time.Instant expire)是否存在某个键longlast(K key)获取对应键的剩余存活时间default VputIfAbsent(K key, V value, long alive)若不存在则存入voidset(K key, V value, long alive)新增或更新一个键值对voidset(K key, V value, long timeout, java.util.concurrent.TimeUnit unit)新增或更新一个键值对voidset(K key, V value, java.time.Instant expire)新增或更新一个键值对-
Methods inherited from interface fun.awooo.dive.cache.common.CommonCache
clear, compute, computeIfAbsent, computeIfPresent, delete, get, get, getOrDefault, has, merge, putIfAbsent, remove, set
-
-
-
-
Method Detail
-
set
void set(K key, V value, java.time.Instant expire)
新增或更新一个键值对- Parameters:
key- 键value- 值expire- 过期时刻
-
set
void set(K key, V value, long timeout, java.util.concurrent.TimeUnit unit)
新增或更新一个键值对- Parameters:
key- 键value- 值timeout- 超时时间unit- 时间单位
-
set
void set(K key, V value, long alive)
新增或更新一个键值对- Parameters:
key- 键value- 值alive- 存活毫秒数, 若为负数, 表明永不过期
-
has
boolean has(K key, java.time.Instant expire)
是否存在某个键- Parameters:
key- 键expire- 若存在, 更新过期时刻- Returns:
- 存在返回 true, 不存在返回 false
-
has
boolean has(K key, long timeout, java.util.concurrent.TimeUnit unit)
是否存在某个键- Parameters:
key- 键timeout- 若存在, 更新超时时间unit- 时间单位- Returns:
- 存在返回 true, 不存在返回 false
-
has
boolean has(K key, long alive)
是否存在某个键- Parameters:
key- 键alive- 若存在, 更新存活毫秒数, 若为负数, 表明永不过期- Returns:
- 存在返回 true, 不存在返回 false
-
get
V get(K key, java.time.Instant expire)
获取键对应的值- Parameters:
key- 键expire- 若存在, 更新过期时刻- Returns:
- 存在返回对应的值, 不存在返回 null
-
get
V get(K key, long timeout, java.util.concurrent.TimeUnit unit)
获取键对应的值- Parameters:
key- 键timeout- 若存在, 更新超时时间unit- 时间单位- Returns:
- 存在返回对应的值, 不存在返回 null
-
get
V get(K key, long alive)
获取键对应的值- Parameters:
key- 键alive- 若存在, 更新存活毫秒数, 若为负数, 表明永不过期- Returns:
- 存在返回对应的值, 不存在返回 null
-
expire
long expire(K key)
获取对应键的过期时间- Parameters:
key- 键- Returns:
- 过期时间, 单位毫秒, 若不存在, 返回 0
-
last
long last(K key)
获取对应键的剩余存活时间- Parameters:
key- 键- Returns:
- 剩余存活时间, 单位毫秒, 若不存在, 返回 0
-
putIfAbsent
default V putIfAbsent(K key, V value, long alive)
若不存在则存入- Parameters:
key- 键value- 值alive- 若存在, 更新存活毫秒数, 若为负数, 表明永不过期- Returns:
- 值
-
get
default V get(K key, java.util.function.Supplier<V> supplier, long alive)
获取或生成- Parameters:
key- 键supplier- 生产者alive- 若存在, 更新存活毫秒数, 若为负数, 表明永不过期- Returns:
- 值
-
-