Jedis工具类
配置文件
host=127.0.0.1 port=6379 maxTotal=50 maxIdle=10
代码
package com.czy.util; import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisPool; import redis.clients.jedis.JedisPoolConfig; import java.io.IOException; import java.util.Properties; public class JedisUtils { private static JedisPool jedisPool; static { Properties pro = new Properties(); try { pro.load(JedisUtils.class.getClassLoader().getResourceAsStream("jedis.properties")); } catch (IOException e) { e.printStackTrace(); } JedisPoolConfig config = new JedisPoolConfig(); config.setMaxTotal(Integer.parseInt(pro.getProperty("maxTotal"))); config.setMaxIdle(Integer.parseInt(pro.getProperty("maxIdle"))); jedisPool = new JedisPool(config,pro.getProperty("host"),Integer.parseInt(pro.getProperty("port"))); } public static Jedis getJedis(){ return jedisPool.getResource(); } }

 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号