Interface CacheLoader<K,V>
- Type Parameters:
K- the type of keys | 键类型V- the type of values | 值类型
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Cache Loader SPI - Synchronous cache value loader interface
缓存加载器 SPI - 同步缓存值加载接口
Provides interface for loading cache values when they are not present.
提供缓存值不存在时的加载接口。
Features | 主要功能:
- Single value loading - 单值加载
- Batch loading - 批量加载
- Reload/refresh support - 重新加载/刷新支持
Usage Examples | 使用示例:
CacheLoader<String, User> loader = key -> userDao.findById(key);
// Or with batch loading - 或者批量加载
CacheLoader<String, User> batchLoader = new CacheLoader<>() {
public User load(String key) { return userDao.findById(key); }
public Map<String, User> loadAll(Set<String> keys) {
return userDao.findByIds(keys);
}
};
Security | 安全性:
- Thread-safe: Implementation dependent - 线程安全: 取决于实现
- Null-safe: May return null for missing values - 空值安全: 可为缺失值返回 null
- Since:
- JDK 25, opencode-base-cache V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionLoad value for single key 加载单个键的值Batch load values for multiple keys (default: load one by one) 批量加载多个键的值(默认:逐个加载)default VReload value (default: just load again) 重新加载值(默认:直接重新加载)
-
Method Details
-
load
-
loadAll
-
reload
-