|
@@ -39,8 +39,9 @@ public class RedisUtil {
|
|
|
* @param key
|
|
|
* @param clazz 目标对象类型
|
|
|
* @return
|
|
|
+ * @throws Exception
|
|
|
*/
|
|
|
- public static <T> T get(String key, Class<T> clazz) {
|
|
|
+ public static <T> T get(String key, Class<T> clazz) throws Exception {
|
|
|
String value = get(key);
|
|
|
return Objects.isNull(value) ? null : JsonUtil.toObject(value, clazz);
|
|
|
}
|
|
@@ -68,8 +69,9 @@ public class RedisUtil {
|
|
|
* 保存
|
|
|
* @param key
|
|
|
* @param obj
|
|
|
+ * @throws Exception
|
|
|
*/
|
|
|
- public static void set(String key, Object obj) {
|
|
|
+ public static void set(String key, Object obj) throws Exception {
|
|
|
redisTemplate.opsForValue().set(key, JsonUtil.toJson(obj));
|
|
|
}
|
|
|
|
|
@@ -79,8 +81,9 @@ public class RedisUtil {
|
|
|
* @param obj
|
|
|
* @param timeout 超时时间
|
|
|
* @param unit 时间单位
|
|
|
+ * @throws Exception
|
|
|
*/
|
|
|
- public static void set(String key, Object obj, long timeout, TimeUnit unit) {
|
|
|
+ public static void set(String key, Object obj, long timeout, TimeUnit unit) throws Exception {
|
|
|
redisTemplate.opsForValue().set(key, JsonUtil.toJson(obj), timeout, unit);
|
|
|
}
|
|
|
|