jedis工具类:java操作redis数据库

学完redis,需要在java客户端中使用Jedis,作为连接redis的工具:

JedisUtils工具类:

public class JedisUtils{
   //定义一个连接池对象:
   private final static JedisPool POOL;
   static {
       JedisPoolConfig config = new JedisPoolConfig();
    config.setMaxTotal(50);
    POOL = new JedisPool(config,"192.168.1.115",6379); 
   }
  //从池中获取连接
  public static Jedis getJedis(){
    return POOL.getResource();
  }
}

猜你喜欢

转载自www.cnblogs.com/superdrew/p/9975786.html