- Type Parameters:
K - 键类型
V - 值类型
- All Implemented Interfaces:
CacheX<K,V>
public class NoOpCache<K,V>
extends Object
implements CacheX<K,V>
无缓存实现,用于快速关闭缓存
空操作缓存实现,所有方法都是空操作,不执行任何实际缓存功能。 主要用于需要快速关闭缓存功能的场景,避免修改大量代码。
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Constructor Summary
Constructors
-
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
NoOpCache
public NoOpCache()
-
Method Details
-
read
- Specified by:
read in interface CacheX<K,V>
- Parameters:
key - 缓存键
- Returns:
- 始终返回null
-
write
public void write(K key,
V value,
long expire)
- Specified by:
write in interface CacheX<K,V>
- Parameters:
key - 缓存键
value - 缓存值
expire - 过期时间(毫秒)
-
read
- Specified by:
read in interface CacheX<K,V>
- Parameters:
keys - 缓存键集合
- Returns:
- 始终返回空Map
-
write
public void write(Map<K,V> keyValueMap,
long expire)
- Specified by:
write in interface CacheX<K,V>
- Parameters:
keyValueMap - 键值映射
expire - 过期时间(毫秒)
-
remove
public void remove(K... keys)
- Specified by:
remove in interface CacheX<K,V>
- Parameters:
keys - 要移除的缓存键
-
clear
public void clear()
- Specified by:
clear in interface CacheX<K,V>