最新代码
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.starry.common.redis;
|
||||
|
||||
import org.springframework.dao.QueryTimeoutException;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.ValueOperations;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -26,7 +27,12 @@ public class RedisCache {
|
||||
*/
|
||||
public <T> T getCacheObject(final String key) {
|
||||
ValueOperations<String, Object> operations = redisTemplate.opsForValue();
|
||||
return (T) operations.get(key);
|
||||
try {
|
||||
return (T) operations.get(key);
|
||||
} catch (QueryTimeoutException e) {
|
||||
throw new RuntimeException("系统错误,通讯异常");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user