Merge pull request #2129 from dataease/pr@dev@fix_redis_cache

fix: redis缓存存取方案一致
This commit is contained in:
fit2cloud-chenyw 2022-04-18 10:49:39 +08:00 committed by GitHub
commit 58cd1c1431
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);