From b6443e0c01553ced0592e6e6cec7464e9b07b3c1 Mon Sep 17 00:00:00 2001
From: 疯狂的狮子li <15040126243@163.com>
Date: 星期三, 20 十月 2021 13:53:36 +0800
Subject: [PATCH] update quartz改为保留一个版本

---
 ruoyi-common/src/main/java/com/ruoyi/common/core/mybatisplus/cache/MybatisPlusRedisCache.java |   31 ++++++++++---------------------
 1 files changed, 10 insertions(+), 21 deletions(-)

diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/mybatisplus/cache/MybatisPlusRedisCache.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/mybatisplus/cache/MybatisPlusRedisCache.java
index 0e21d70..c790c66 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/core/mybatisplus/cache/MybatisPlusRedisCache.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/mybatisplus/cache/MybatisPlusRedisCache.java
@@ -1,7 +1,7 @@
 package com.ruoyi.common.core.mybatisplus.cache;
 
 import cn.hutool.extra.spring.SpringUtil;
-import com.ruoyi.common.core.redis.RedisCache;
+import com.ruoyi.common.utils.RedisUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.ibatis.cache.Cache;
 import org.springframework.data.redis.connection.RedisServerCommands;
@@ -15,14 +15,16 @@
 /**
  * mybatis-redis 浜岀骇缂撳瓨
  *
+ * 浣跨敤鏂规硶 閰嶇疆鏂囦欢寮�鍚� mybatis-plus 浜岀骇缂撳瓨
+ * 鍦� XxxMapper.java 绫讳笂娣诲姞娉ㄨВ @CacheNamespace(implementation = MybatisPlusRedisCache.class, eviction = MybatisPlusRedisCache.class)
+ *
+ * @deprecated 3.4.0鍒犻櫎 鎺ㄨ崘浣跨敤spirng-cache
  * @author Lion Li
  */
 @Slf4j
 public class MybatisPlusRedisCache implements Cache {
 
 	private final ReadWriteLock readWriteLock = new ReentrantReadWriteLock(true);
-
-	private RedisCache redisCache;
 
 	private String id;
 
@@ -40,23 +42,16 @@
 
 	@Override
 	public void putObject(Object key, Object value) {
-		if (redisCache == null) {
-			redisCache = SpringUtil.getBean(RedisCache.class);
-		}
 		if (value != null) {
-			redisCache.setCacheObject(key.toString(), value);
+			RedisUtils.setCacheObject(key.toString(), value);
 		}
 	}
 
 	@Override
 	public Object getObject(Object key) {
-		if (redisCache == null) {
-			//鐢变簬鍚姩鏈熼棿娉ㄥ叆澶辫触锛屽彧鑳借繍琛屾湡闂存敞鍏ワ紝杩欐浠g爜鍙互鍒犻櫎
-			redisCache = SpringUtil.getBean(RedisCache.class);
-		}
 		try {
 			if (key != null) {
-				return redisCache.getCacheObject(key.toString());
+				return RedisUtils.getCacheObject(key.toString());
 			}
 		} catch (Exception e) {
 			e.printStackTrace();
@@ -67,11 +62,8 @@
 
 	@Override
 	public Object removeObject(Object key) {
-		if (redisCache == null) {
-			redisCache = SpringUtil.getBean(RedisCache.class);
-		}
 		if (key != null) {
-			redisCache.deleteObject(key.toString());
+			RedisUtils.deleteObject(key.toString());
 		}
 		return null;
 	}
@@ -79,12 +71,9 @@
 	@Override
 	public void clear() {
 		log.debug("娓呯┖缂撳瓨");
-		if (redisCache == null) {
-			redisCache = SpringUtil.getBean(RedisCache.class);
-		}
-		Collection<String> keys = redisCache.keys("*:" + this.id + "*");
+		Collection<String> keys = RedisUtils.keys("*:" + this.id + "*");
 		if (!CollectionUtils.isEmpty(keys)) {
-			redisCache.deleteObject(keys);
+			RedisUtils.deleteObject(keys);
 		}
 	}
 

--
Gitblit v1.9.3