import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
/**
* @author 小工匠
* @version v1.0
* @create 2020-03-23 22:27
* @motto show me the code ,change the word
* @blog https://artisan.blog.csdn.net/
* @description
**/
public class Test {
public static void main(String[] args) {
JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
jedisPoolConfig.setMaxTotal(20);
jedisPoolConfig.setMaxIdle(10);
jedisPoolConfig.setMinIdle(5);
JedisPool jedisPool = new JedisPool(jedisPoolConfig,"192.168.18.130",6379,3000, null);
Jedis jedis = null;
try{
jedis = jedisPool.getResource();
jedis.set("artisan","biubiubiu~");
String value = jedis.get("artisan");
System.out.println(value);
}catch (Exception e){
e.printStackTrace();
} finally {
//注意这里不是关闭连接,在JedisPool模式下,Jedis会被归还给资源池。
if (jedis != null) jedis.close();
}
}
}