From 1e92eff67b997263ecefa255c63eb6641c47b57f Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期五, 14 六月 2019 10:22:33 +0800
Subject: [PATCH] 设备消息BUG解决,品牌

---
 fanli/src/main/java/com/yeshi/fanli/util/RedisManager.java |   65 +++++++++++++++++++++++++++++++-
 1 files changed, 62 insertions(+), 3 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/util/RedisManager.java b/fanli/src/main/java/com/yeshi/fanli/util/RedisManager.java
index 8e53740..0f48288 100644
--- a/fanli/src/main/java/com/yeshi/fanli/util/RedisManager.java
+++ b/fanli/src/main/java/com/yeshi/fanli/util/RedisManager.java
@@ -6,6 +6,7 @@
 import javax.annotation.Resource;
 
 import org.springframework.stereotype.Component;
+import org.yeshi.utils.JsonUtil;
 
 import com.google.gson.Gson;
 import com.google.gson.reflect.TypeToken;
@@ -22,7 +23,6 @@
 import com.yeshi.fanli.util.taobao.TaoBaoCouponUtil;
 import com.yeshi.fanli.util.taobao.TaoBaoUtil;
 import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
-import org.yeshi.utils.JsonUtil;
 
 import net.sf.json.JSONArray;
 import redis.clients.jedis.Jedis;
@@ -111,7 +111,7 @@
 		}
 	}
 
-	public void expire(String key,int seconds) {
+	public void expire(String key, int seconds) {
 		Jedis jedis = jedisPool.getResource();
 		try {
 			jedis.expire(key, seconds);
@@ -253,7 +253,7 @@
 			long count = jedis.incr(key);
 			if (count == 1)
 				jedis.expire(key, 5);
-			if (count >= 100)
+			if (count >= 10)
 				return true;
 			else
 				return false;
@@ -509,4 +509,63 @@
 		return null;
 	}
 
+	/**
+	 * 淇濆瓨瀵硅薄
+	 * 
+	 * @param T
+	 * @param key
+	 * @param seconds
+	 */
+	public void saveObj(Class<?> clazz, String key, Integer seconds) {
+		if (clazz == null)
+			return;
+		String value = new Gson().toJson(clazz);
+		if (seconds != null)
+			cacheCommonString(key, value, seconds);
+		else
+			cacheCommonString(key, value);
+	}
+
+	/**
+	 * 淇濆瓨鍒楄〃
+	 * 
+	 * @param clazzList
+	 * @param key
+	 * @param seconds
+	 */
+	public <T> T saveObjList(List<T> clazzList, String key, Integer seconds) {
+		if (clazzList == null)
+			return null;
+		String value = new Gson().toJson(clazzList);
+		if (seconds != null)
+			cacheCommonString(key, value, seconds);
+		else
+			cacheCommonString(key, value);
+		return null;
+	}
+
+	/**
+	 * 鑾峰彇瀵硅薄
+	 * 
+	 * @param clazz
+	 * @param key
+	 * @return
+	 */
+	public Class<?> getObj(Class<?> clazz, String key) {
+		String value = getCommonString(key);
+		return (Class<?>) new Gson().fromJson(value, clazz);
+	}
+
+	/**
+	 * 鑾峰彇鍒楄〃
+	 * 
+	 * @param clazz
+	 * @param key
+	 * @return
+	 */
+	public <T> List<T> getObjList(Class<T> clazz, String key) {
+		String value = getCommonString(key);
+		return JsonUtil.jsonToList(value, clazz);
+	}
+
 }

--
Gitblit v1.8.0