Snapshot của alibaba/jetcache: 5.6k★ · Java · Backend. JetCache is a Java cache framework.
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
JetCache is a Java cache abstraction which provides uniform usage for different caching solutions.
It provides more powerful annotations than those in Spring Cache. The annotations in JetCache supports native TTL,
two level caching, and automatically refresh in distrubuted environments, also you can manipulate Cache instance by your code.
Currently, there are four implementations: RedisCache, TairCache(not open source on github), CaffeineCache (in memory) and a simple LinkedHashMapCache (in memory).
Full features of JetCache:
Manipulate cache through uniform Cache API.
Declarative method caching using annotations with TTL(Time To Live) and two level caching support
Create & configure Cache instance with cache manager
Automatically collect access statistics for Cache instance and method level cache
The strategy of key generation and value serialization can be customized
Cache key convertor supported: fastjson2/jackson/jackson3; Value encoder/decoder supported: java/kryo/kryo5
Distributed cache auto refresh and distributed lock. (2.2+)
Asynchronous access using Cache API (2.2+, with redis lettuce client)
Invalidate local caches (in all JVM process) after updates (2.7+)
Spring Boot support
requirements:
JDK17+ (jetcache 2.8+); JDK8+ (jetcache 2.7 and earlier)
Spring Framework6.x+ (optional, with annotation support)
Spring Boot3.x+ (optional)
Visit docs for more details.
Getting started
Method cache
Declare method cache using @Cached annotation. expire = 3600 indicates that the elements will expire in 3600 seconds after being set.
JetCache automatically generates the cache key with all the parameters.
public interface UserService {
@Cached(expire = 3600, cacheType = CacheType.REMOTE)
User getUserById(long userId);
}
Using key attribute to specify cache key using SpEL script.
In order to use parameter name such as key="#userId", the -parameters javac compiler flag should be set. Otherwise, use index to access parameters like key="args[0]"
CachePenetrationProtect annotation indicates that the cache will be loaded synchronously in multi-thread environment.
Cache API
Create a Cache instance with CacheManager:
@Autowired
private CacheManager cacheManager;
private Cache<String, UserDO> userCache;
@PostConstruct
public void init() {
QuickConfig qc = QuickConfig.newBuilder("userCache")
.expire(Duration.ofSeconds(100))
.cacheType(CacheType.BOTH) // two level cache
.localLimit(50)
.syncLocal(true) // invalidate local cache in all jvm process after update
.build();
userCache = cacheManager.getOrCreateCache(qc);
}
The code above create a Cache instance. cacheType = CacheType.BOTH define a two level cache (a local in-memory-cache and a remote cache system) with local elements limited upper to 50(LRU based evict). You can use it like a map:
@SpringBootApplication
@EnableMethodCache(basePackages = "com.company.mypackage")
@EnableCreateCacheAnnotation // deprecated in jetcache 2.7, can be removed if @CreateCache is not used
public class MySpringBootApp {
public static void main(String[] args) {
SpringApplication.run(MySpringBootApp.class);
}
}
spring boot application.yml config:
jetcache:
statIntervalMinutes: 15
areaInCacheName: false
decodeFilterAllowPatterns:
- com.yourcompany. #add your package here, or set decodeFilterEnabled: false to disable the filter
local:
default:
type: linkedhashmap #other choose:caffeine
keyConvertor: fastjson2 #other choose:fastjson(same as fastjson2)/jackson/jackson3
limit: 100
remote:
default:
type: redis
keyConvertor: fastjson2 #other choose:fastjson(same as fastjson2)/jackson/jackson3
broadcastChannel: projectA
valueEncoder: java #other choose:kryo/kryo5
valueDecoder: java #other choose:kryo/kryo5
poolConfig:
minIdle: 5
maxIdle: 20
maxTotal: 50
host: ${redis.host}
port: ${redis.port}
Visit detail configuration for more instructions
More docs
Visit docs for more details.
For upgrade see changelog and compatibility notes.
Có — alibaba/jetcache phát hành theo license Apache-2.0, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/alibaba/jetcache.
alibaba/jetcache có website riêng không?
TopGit chưa ghi nhận URL trang chủ cho alibaba/jetcache. Phần README ở tab phía trên thường có link demo, hoặc xem mô tả GitHub của repo.
alibaba/jetcache dùng license gì?
alibaba/jetcache phát hành theo license Apache-2.0. Nên mở file LICENSE trên GitHub để xác nhận — license metadata đôi khi lệch với thực tế dự án.
alibaba/jetcache là gì?
alibaba/jetcache (alibaba/jetcache) là dự án Java trên GitHub. Theo mô tả gốc: JetCache is a Java cache framework.
Cùng nhóm Backend còn repo nào?
alibaba/jetcache thuộc nhóm Backend trên TopGit, cùng 6 topic GitHub. Trang Trending và Topics liệt kê các repo cùng số sao và cùng ngôn ngữ để so sánh.
Đọc thêm về alibaba/jetcache ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/alibaba/jetcache là nguồn chính thức.
Vì sao alibaba/jetcache được xếp vào nhóm Backend?
TopGit xếp alibaba/jetcache vào nhóm Backend dựa trên GitHub topics và mô tả của repo (gắn thẻ: "cache", "java", "jcache"). Việc phân loại dựa trên metadata thật của repo, không phải đoán theo cảm tính biên tập.
Đọc đầy đủ README ở tab phía trên.
Vẫn đang phân vân về jetcache?
Một cú bấm sẽ gửi câu hỏi kèm trang này cho AI — xem AI nói gì về jetcache.