In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces you how to carry out JedisPool.java analysis, the content is very detailed, interested friends can refer to, hope to be helpful to you.
Package redis.clients.jedis;import redis.clients.util.FixedResourcePool;public class JedisPool extends FixedResourcePool {private String host;//IP private int port;// port private int timeout;// timeout public JedisPool (String host) {/ / set IP this.host = host; this.port = Protocol.DEFAULT_PORT;} public JedisPool (String host, int port) {/ / set IP and port this.host = host This.port = port;} public JedisPool (String host, int port, int timeout) {/ / set IP and port, timeout this.host = host; this.port = port; this.timeout = timeout;} @ Override protected Jedis createResource () {/ / always connect, return jedis and have been connected. Jedis jedis = new Jedis (this.host, this.port, this.timeout); boolean done = false; while (! done) {try {jedis.connect (); done = true;} catch (Exception e) {try {Thread.sleep } catch (InterruptedException E1) {} return jedis;} @ Override protected void destroyResource (Jedis jedis) {/ / destroy resource if (jedis! = null & & jedis.isConnected ()) {try {jedis.quit (); jedis.disconnect () } catch (Exception e) {} @ Override protected boolean isResourceValid (Jedis jedis) {/ / whether the resource is valid try {return jedis.isConnected () & & jedis.ping () .equals ("PONG");} catch (Exception ex) {return false This is the end of the analysis on how to conduct JedisPool.java. I hope the above content can be helpful to you and learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.