| | |
| | | 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;
|
| | |
| | | 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;
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | public void expire(String key,int seconds) {
|
| | | public void expire(String key, int seconds) {
|
| | | Jedis jedis = jedisPool.getResource();
|
| | | try {
|
| | | jedis.expire(key, seconds);
|
| | |
| | | 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);
|
| | | }
|
| | |
|
| | | }
|