From 413481685a193a9719277a97146391e2ba9f639a Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Mon, 18 Apr 2022 10:48:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20redis=E7=BC=93=E5=AD=98=E5=AD=98?= =?UTF-8?q?=E5=8F=96=E6=96=B9=E6=A1=88=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/dataease/listener/util/CacheUtils.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/backend/src/main/java/io/dataease/listener/util/CacheUtils.java b/backend/src/main/java/io/dataease/listener/util/CacheUtils.java index df13083c45..22ebed424a 100644 --- a/backend/src/main/java/io/dataease/listener/util/CacheUtils.java +++ b/backend/src/main/java/io/dataease/listener/util/CacheUtils.java @@ -26,8 +26,8 @@ public class CacheUtils { public static Object get(String cacheName, Object key) { if (getCacheManager() instanceof RedisCacheManager) { org.springframework.cache.Cache cache = getCacheManager().getCache(cacheName); - if (null == cache) return null; - return cache.get(key); + if (null == cache || null == cache.get(key)) return null; + return cache.get(key).get(); } Element element = cache(cacheName).get(key); if (null == element) return null; @@ -36,9 +36,12 @@ public class CacheUtils { public static void put(String cacheName, Object key, Object value, Integer ttl, Integer tti) { if (getCacheManager() instanceof RedisCacheManager) { - RedisTemplate redisTemplate = (RedisTemplate) CommonBeanFactory.getBean("redisTemplate"); + /*RedisTemplate redisTemplate = (RedisTemplate) CommonBeanFactory.getBean("redisTemplate"); ValueOperations valueOperations = redisTemplate.opsForValue(); - valueOperations.set(cacheName + "::" + key , value ); + valueOperations.set(cacheName + "::" + key , value );*/ + org.springframework.cache.Cache cache = getCacheManager().getCache(cacheName); + if (null == cache) return; + cache.put(key, value); return; } Element e = new Element(key, value);