Java examples for Big Data:Jedis
Get object from redis
import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.alibaba.fastjson.JSON; import java.io.Serializable; import allen.commons.redis.api.JedisAPI; public class Test1 { private final static Logger logger = LoggerFactory .getLogger(Test1.class); public static void main(String[] args) { TestBean1 bean1 = TestBean1.getInstance(111, "allenOne"); /*JedisAPI.setObj("HQYG:ALLEN:TEST:allen", bean1); //w w w . j a v a 2 s . c o m JedisAPI.setString("HQYG:ALLEN:TEST:allenone", "allen");*/ TestBean1 test = JedisAPI.getObj("HQYG:ALLEN:TEST:allen", TestBean1.class); System.out.println(JSON.toJSONString(test)); logger.info("??????!!!"); } } class TestBean1 implements Serializable { private static final long serialVersionUID = -2730211713088606559L; private Integer id; private String name; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public static TestBean1 getInstance(Integer id, String name) { TestBean1 bean = new TestBean1(); bean.setId(id); bean.setName(name); return bean; } public static void main(String[] args) { // TODO Auto-generated method stub } }