- All Known Implementing Classes:
GuavaCache,MemcachedCache,MemoryCache,NoOpCache,RedisCache,RedisClusterCache
public interface CacheX<K,V>
缓存接口
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Method Summary
Modifier and TypeMethodDescriptionvoidclear()清空缓存信息default booleancontainsKey(K key) 是否存在key,如果对应key的value值已过期,也返回falseread(Collection<K> keys) 从缓存中获得一组对象信息从缓存中获得对象void从缓存中移除对象void将对象加入到缓存,使用指定失效时长void将对象加入到缓存,使用指定失效时长
-
Method Details
-
read
从缓存中获得对象- Parameters:
key- 键- Returns:
- 键对应的对象
-
read
从缓存中获得一组对象信息- Parameters:
keys- 多个键- Returns:
- 值对象
-
write
将对象加入到缓存,使用指定失效时长- Parameters:
key- 键value- 缓存的对象expire- 失效时长,单位毫秒
-
write
将对象加入到缓存,使用指定失效时长- Parameters:
map- 缓存的对象expire- 失效时长,单位毫秒- See Also:
-
containsKey
是否存在key,如果对应key的value值已过期,也返回false- Parameters:
key- 缓存key- Returns:
- true:存在key,并且value没过期;false:key不存在或者已过期
-
remove
从缓存中移除对象- Parameters:
keys- 键
-
clear
void clear()清空缓存信息
-