jedis使用方法:
1:生成一个jedis对象<br>Jedis jedis = new Jedis("127.0.0.1",6379);
2:执行set<br>jedis.set("hello","world");
3:执行get<br>String value = jedis.get("hello");
4:finally中关闭jedis<br>jedis.close
其他命令使用类似
jedis没有提供序列化工具,可以使用第三方的,如protobuf,thrift
Jedis连接池使用方法
1:无需每次连接都生产jedis对象,降低消耗
2:使用连接池保护和控制资源使用
1:GenericObjectPoolConfig config = new GenericObjectPoolConfig();
2:JedisPool pool = new JedisPool(config,"127.0.0.1",6379);
3:Jedis jedis = pool.getResouce();
4:直接使用jedis
5:jedis.close();