JetCache is a Java library from Alibaba that provides a consistent way to add caching to your application, regardless of which caching system sits underneath. Caching means storing the results of slow operations, like database queries, in faster memory so that repeated requests can be answered immediately. JetCache supports several backends: Redis for remote distributed caching, Caffeine and LinkedHashMap for in-memory caching on a single machine, and a two-level setup that combines both. The most common way to use it is through annotations on your Java methods. You add a @Cached annotation to a method, specify how long the result should be kept, and JetCache handles the rest. When the method is called, JetCache checks the cache first, if the value is there and still fresh, it returns it directly. You can also add @CacheUpdate and @CacheInvalidate annotations to methods that modify data, so the cache stays consistent. For more control, you can create cache instances directly in code and use them like a map, calling get, put, and remove. The library also supports automatic background refresh of cached values before they expire, a distributed lock feature to prevent multiple servers from simultaneously recalculating the same value, and asynchronous access for non-blocking reads. JetCache integrates with Spring Boot through a starter dependency and a YAML configuration block. It collects access statistics automatically so you can monitor cache hit rates. The library requires Java 17 or later for version 2.8 and above, and Java 8 for earlier versions. It is licensed under Apache 2.0.
← alibaba on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.