forked from github/dataease
Merge pull request #2129 from dataease/pr@dev@fix_redis_cache
fix: redis缓存存取方案一致
This commit is contained in:
commit
58cd1c1431
@ -26,8 +26,8 @@ public class CacheUtils {
|
|||||||
public static Object get(String cacheName, Object key) {
|
public static Object get(String cacheName, Object key) {
|
||||||
if (getCacheManager() instanceof RedisCacheManager) {
|
if (getCacheManager() instanceof RedisCacheManager) {
|
||||||
org.springframework.cache.Cache cache = getCacheManager().getCache(cacheName);
|
org.springframework.cache.Cache cache = getCacheManager().getCache(cacheName);
|
||||||
if (null == cache) return null;
|
if (null == cache || null == cache.get(key)) return null;
|
||||||
return cache.get(key);
|
return cache.get(key).get();
|
||||||
}
|
}
|
||||||
Element element = cache(cacheName).get(key);
|
Element element = cache(cacheName).get(key);
|
||||||
if (null == element) return null;
|
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) {
|
public static void put(String cacheName, Object key, Object value, Integer ttl, Integer tti) {
|
||||||
if (getCacheManager() instanceof RedisCacheManager) {
|
if (getCacheManager() instanceof RedisCacheManager) {
|
||||||
RedisTemplate redisTemplate = (RedisTemplate) CommonBeanFactory.getBean("redisTemplate");
|
/*RedisTemplate redisTemplate = (RedisTemplate) CommonBeanFactory.getBean("redisTemplate");
|
||||||
ValueOperations valueOperations = redisTemplate.opsForValue();
|
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;
|
return;
|
||||||
}
|
}
|
||||||
Element e = new Element(key, value);
|
Element e = new Element(key, value);
|
||||||
|
Loading…
Reference in New Issue
Block a user