JetCache 是一个 Java 缓存框架。
JetCache 是一个 Java 缓存抽象框架,为不同的缓存解决方案提供了统一的使用方式。
它提供了比 Spring Cache 更强大的注解。JetCache 中的注解支持原生 TTL、
两级缓存,以及在分布式环境中的自动刷新,你还可以通过代码直接操作
Cache
实例。
目前共有四种实现:
RedisCache
、
TairCache
(在 GitHub 上不支持 开源)、
CaffeineCache
(内存中)以及一个简单的
LinkedHashMapCache
(内存中)。
JetCache 的完整特性:
Cache
实例
Cache
实例和方法级缓存的访问统计信息
fastjson2
/jackson
/
jackson3
;支持的值编码器/解码器:java
/
kryo
/
kryo5
环境要求:
访问 文档 了解更多详情。
使用
@Cached
注解声明方法缓存。
expire = 3600
表示元素在设置后 3600 秒过期。
JetCache 会自动根据所有参数生成缓存键。
public interface UserService {
@Cached(expire = 3600, cacheType = CacheType.REMOTE)
User getUserById(long userId);
}使用
key
使用 SpEL 脚本指定缓存键的属性。
```java
public interface UserService {@Cached(name="userCache-", key="#userId", expire = 3600) User ge
暂无开放 Issues,或尚未同步最近议题。