Redis实现List存取
写
先将list对象序列化为byte[],然后写入
/**
* 设置 list
* @param <T>
* @param key
* @param list
*/
public <T extends Serializable> void setList(String key , List<T> list,int seconds){
try {
ListTranscoder<T> listTranscoder = new ListTranscoder<T>();
bset(key,listTranscoder.serialize(list),seconds);
} catch (Exception e) {
log.error("Set key error : "+e);
}
}
public void bset(String key, byte[] value, int seconds){
Jedis jedis = null;
try {
jedis=getJedis();
jedis.set(key.getBytes(), value);
jedis.expire(key.getBytes(), seconds);
} catch (Exception e) {
log