/** * Close. */ public void close() { pool.close(); } }
@Override public void disconnect() throws IOException { // do nothing for direct Redis connection, close connection for Sentinel if(isSentinel && sentinel!=null) { sentinel.close(); } }
public static void close() { if (sentinelPool != null) { sentinelPool.close(); sentinelPool = null; } }
@Override public void disconnect() throws IOException { // do nothing for direct Redis connection, close connection for Sentinel if(isSentinel && sentinel!=null) { sentinel.close(); } }
/** * Closes the Jedis instances. */ @Override public void close() throws IOException { if (this.jedisPool != null) { this.jedisPool.close(); } if (this.jedisSentinelPool != null) { this.jedisSentinelPool.close(); } }
@Override public void disconnect() throws IOException { if (isSentinel && sentinel != null) { sentinel.close(); } else { redis.close(); } }
/** * Closes the Jedis instances. */ @Override public void close() throws IOException { if (this.jedisPool != null) { this.jedisPool.close(); } if (this.jedisSentinelPool != null) { this.jedisSentinelPool.close(); } }
@Override public void disconnect() throws IOException { if (isSentinel && sentinel != null) { sentinel.close(); } else { redis.close(); } }
protected void close() { available = false; if (sentinelPool != null) { JedisSentinelPool copy = this.sentinelPool; this.sentinelPool = null; copy.close(); } if (jedis != null) { JedisPool copy = this.jedis; this.jedis = null; copy.close(); } }
/** * 释放连接池 * @throws IOException */ @Override public void close() throws IOException { if(single != null) single.close(); if(sentinel != null) sentinel.close(); if(cluster != null) cluster.close(); if(sharded != null) sharded.close(); }
/** * redis 主从测试 */ @Test public void sentinelTest() { Set<String> sentinels = new HashSet<String>(); sentinels.add(new HostAndPort("192.168.46.137", 26376).toString()); sentinels.add(new HostAndPort("192.168.46.137", 26377).toString()); sentinels.add(new HostAndPort("192.168.46.137", 26378).toString()); sentinels.add(new HostAndPort("192.168.46.137", 26379).toString()); JedisSentinelPool sentinelPool = new JedisSentinelPool("mymaster", sentinels, "123456"); System.out.println("Current master: " + sentinelPool.getCurrentHostMaster().toString()); Jedis master = sentinelPool.getResource(); master.set("username","jager"); System.out.println(master.get("username")); sentinelPool.close(); sentinelPool.destroy(); }
jedisSentinelPool.close(); jedisSentinelPool.destroy();