File tree Expand file tree Collapse file tree 7 files changed +31
-20
lines changed
src/main/java/com/xxl/cache/core
xxl-cache-sample-frameless
xxl-cache-sample-springboot Expand file tree Collapse file tree 7 files changed +31
-20
lines changed Original file line number Diff line number Diff line change @@ -129,16 +129,28 @@ public XxlCacheFactory xxlCacheFactory() {
129129示例代码:
130130```
131131String category = "user";
132+ long survivalTime = 60*1000;
132133String key = "user03";
133134
134- // 缓存写入
135- XxlCacheHelper.getCache(category).set(key, value);
136-
137- // 缓存查询
138- String value = XxlCacheHelper.getCache(category).get(key);
139-
140- // 缓存删除
141- XxlCacheHelper.getCache(category).del(key);
135+ /**
136+ * 1、定义缓存对象,并指定 “缓存category + 过期时间”
137+ */
138+ XxlCacheHelper.XxlCache userCache = XxlCacheHelper.getCache(category, survivalTime);
139+
140+ /**
141+ * 2、缓存写:按照 L1 -> L2 顺序依次写缓存,同时借助内部广播机制更新全局L1节点缓存;
142+ */
143+ userCache.set(key, value);
144+
145+ /**
146+ * 3、缓存读:按照 L1 -> L2 顺序依次读取缓存,如果L1存在缓存则返回,否则读取L2缓存并同步L1;
147+ */
148+ userCache.get(key);
149+
150+ /**
151+ * 4、缓存删:按照 L1 -> L2 顺序依次删缓存,同时借助内部广播机制更新全局L1节点缓存;
152+ */
153+ userCache.del(key);
142154...
143155
144156```
@@ -197,7 +209,8 @@ XXL-CACHE 定位多级缓存框架,高效组合本地缓存和分布式缓存(
197209- 7、【优化】核心依赖推送maven中央仓库, 方便用户接入和使用;
198210
199211### v1.2.0 Release Notes[ 2025-02-07]
200- - 1、【增强】L2缓存序列化能力强化,支持自定义扩展序列化方案;
212+ - 1、【重构】L2缓存序列化组件抽象,支持自定义扩展序列化方案 (Serializer);
213+ - 2、【优化】移除容易依赖,精简Core体积;
201214
202215### v1.2.1 Release Notes[ 迭代中]
203216- 1、[ 迭代中] 缓存监控:L1、L2缓存命中率,L1缓存容量、内容占用等;
Original file line number Diff line number Diff line change 33 <modelVersion >4.0.0</modelVersion >
44 <groupId >com.xuxueli</groupId >
55 <artifactId >xxl-cache</artifactId >
6- <version >1.1.1-SNAPSHOT </version >
6+ <version >1.2.0 </version >
77 <packaging >pom</packaging >
88
99 <name >${project.artifactId} </name >
3636 <jedis .version>5.2.0</jedis .version>
3737 <!-- caffeine -->
3838 <caffeine .version>2.9.3</caffeine .version>
39- <!-- gson -->
40- <gson .version>2.12.1</gson .version>
4139
4240 <!-- spring-boot -->
4341 <spring-boot .version>2.7.18</spring-boot .version>
Original file line number Diff line number Diff line change 66 <parent >
77 <groupId >com.xuxueli</groupId >
88 <artifactId >xxl-cache</artifactId >
9- <version >1.1.1-SNAPSHOT </version >
9+ <version >1.2.0 </version >
1010 </parent >
1111 <artifactId >xxl-cache-core</artifactId >
12- <version >1.1.1-SNAPSHOT</version >
1312 <packaging >jar</packaging >
1413
1514 <dependencies >
4140 </dependency >
4241
4342 <!-- gson -->
44- <dependency >
43+ <!-- < dependency>
4544 <groupId>com.google.code.gson</groupId>
4645 <artifactId>gson</artifactId>
4746 <version>${gson.version}</version>
48- </dependency >
47+ </dependency>-->
4948
5049 </dependencies >
5150
Original file line number Diff line number Diff line change @@ -18,7 +18,8 @@ public class XxlCacheHelper {
1818 /**
1919 * get cache by category
2020 *
21- * @param category
21+ * @param category cache category
22+ * @param survivalTime survival time length, milliseconds. Expires after the specified time from the current
2223 * @return
2324 */
2425 public static XxlCache getCache (String category , long survivalTime ) {
Original file line number Diff line number Diff line change 66 <parent >
77 <groupId >com.xuxueli</groupId >
88 <artifactId >xxl-cache</artifactId >
9- <version >1.1.1-SNAPSHOT </version >
9+ <version >1.2.0 </version >
1010 </parent >
1111 <artifactId >xxl-cache-samples</artifactId >
1212 <packaging >pom</packaging >
Original file line number Diff line number Diff line change 66 <parent >
77 <groupId >com.xuxueli</groupId >
88 <artifactId >xxl-cache-samples</artifactId >
9- <version >1.1.1-SNAPSHOT </version >
9+ <version >1.2.0 </version >
1010 </parent >
1111 <artifactId >xxl-cache-sample-frameless</artifactId >
1212 <packaging >jar</packaging >
Original file line number Diff line number Diff line change 66 <parent >
77 <groupId >com.xuxueli</groupId >
88 <artifactId >xxl-cache-samples</artifactId >
9- <version >1.1.1-SNAPSHOT </version >
9+ <version >1.2.0 </version >
1010 </parent >
1111 <artifactId >xxl-cache-sample-springboot</artifactId >
1212 <packaging >jar</packaging >
You can’t perform that action at this time.
0 commit comments