一、获取连接
JedisPoolConfig config = new JedisPoolConfig();
JedisPool jedisPool = new JedisPool(config,"127.0.0.1",11222);
Jedis jedis = jedisPool.getResource();
如果是以字节存入的,那么取出的时候要转成Object
public static Object byte2Object(byte[] bytes) {
if (bytes == null || bytes.length == 0){
return null;
}
Object obj = null;
ObjectInputStream inputStream = null;
try {
inputStream = new ObjectInputStream(new ByteArrayInputStream(bytes));
if(inputStream!=null){
obj = inputStream.readObject();
}
} catch (Exception e) {
e.printStackTrace();
}finally{
if(inputStream!=null){
try {
inputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
return obj;
}