當前位置: 首頁>>代碼示例>>Java>>正文


Java JedisCluster.close方法代碼示例

本文整理匯總了Java中redis.clients.jedis.JedisCluster.close方法的典型用法代碼示例。如果您正苦於以下問題:Java JedisCluster.close方法的具體用法?Java JedisCluster.close怎麽用?Java JedisCluster.close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在redis.clients.jedis.JedisCluster的用法示例。


在下文中一共展示了JedisCluster.close方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: exist

import redis.clients.jedis.JedisCluster; //導入方法依賴的package包/類
private ScanPage exist(String cluster, ScanPage scanPage) throws Exception {
	scanPage.setHasMore(false);
	List<D_RedisClusterNode> nodes = clusterNodeService.getAllClusterNodes(cluster);
	Set<HostAndPort> masters = new HashSet<HostAndPort>();
	nodes.forEach(node->{
		masters.add(new HostAndPort(node.getHost(), node.getPort()));
	});
	JedisCluster jedis = new JedisCluster(masters);
	try {
		if(jedis.exists(scanPage.getQuery())){
			scanPage.setKeys(new HashSet<String>());
			scanPage.getKeys().add(scanPage.getQuery());
		}
	} finally {
		jedis.close();
	}
	return scanPage;
}
 
開發者ID:yanfanvip,項目名稱:RedisClusterManager,代碼行數:19,代碼來源:QueryService.java

示例2: testCluster

import redis.clients.jedis.JedisCluster; //導入方法依賴的package包/類
/**測試redis集群方案*/
@Test
public void testCluster(){

    Set<HostAndPort> jedisClusterNodes = new HashSet<HostAndPort>();
    //Jedis Cluster will attempt to discover cluster nodes automatically
    jedisClusterNodes.add(new HostAndPort("192.168.12.90", 7001));
    JedisCluster jc = new JedisCluster(jedisClusterNodes);
    jc.set("foo", "bar");
    String value = jc.get("foo");

    System.out.println(value);
    try {
        jc.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:TomChen001,項目名稱:xmanager,代碼行數:19,代碼來源:SpringRedis.java

示例3: stop

import redis.clients.jedis.JedisCluster; //導入方法依賴的package包/類
@Override
public boolean stop() {

    // 清除出集群集合
    JedisCluster removeRedisCluster = RedisCluster.removeCache(clusterName);

    // 關閉集群鏈接
    try {
        removeRedisCluster.close();
    } catch (IOException e) {
        logger.error(e.getMessage());
    }

    return false;

}
 
開發者ID:T-baby,項目名稱:ICERest-plugin,代碼行數:17,代碼來源:RedisClusterPlugin.java

示例4: main

import redis.clients.jedis.JedisCluster; //導入方法依賴的package包/類
public static void main(String[] args) {
    //加載服務列表
    Set<HostAndPort> redisClusterNodes =new HashSet<>();
    redisClusterNodes.add(new HostAndPort("192.168.137.147",7001));
    redisClusterNodes.add(new HostAndPort("192.168.137.147",7002));
    redisClusterNodes.add(new HostAndPort("192.168.137.147",7003));
    redisClusterNodes.add(new HostAndPort("192.168.137.147",7004));
    redisClusterNodes.add(new HostAndPort("192.168.137.147",7005));
    redisClusterNodes.add(new HostAndPort("192.168.137.147",7006));

    //redis配置
    JedisPoolConfig jedisPoolConfig=new JedisPoolConfig();
    jedisPoolConfig.setMaxTotal(100);
    jedisPoolConfig.setMaxIdle(20);
    jedisPoolConfig.setMaxWaitMillis(-1);
    jedisPoolConfig.setTestOnBorrow(true);

    //redis集群
    JedisCluster jedisCluster=new JedisCluster(redisClusterNodes,6000,1000,jedisPoolConfig);

    PrinterUtils.printELog(jedisCluster.set("username","tom"));
    PrinterUtils.printELog(jedisCluster.set("age","23"));
    PrinterUtils.printILog(jedisCluster.get("username"));
    PrinterUtils.printILog(jedisCluster.get("age"));
    PrinterUtils.printILog(jedisCluster.get("age"));
    PrinterUtils.printILog(jedisCluster.get("username"));
    PrinterUtils.printILog(jedisCluster.get("password"));
    PrinterUtils.printILog(jedisCluster.getClusterNodes());

    try {
        jedisCluster.close();
    } catch (IOException e) {
        e.printStackTrace();
    }


}
 
開發者ID:tomoncle,項目名稱:JavaStudy,代碼行數:38,代碼來源:RedisClusterApp.java

示例5: testJedisClusterRunsWithMultithreaded

import redis.clients.jedis.JedisCluster; //導入方法依賴的package包/類
@Test
public void testJedisClusterRunsWithMultithreaded() throws InterruptedException,
    ExecutionException, IOException {
  Set<HostAndPort> jedisClusterNode = new HashSet<HostAndPort>();
  jedisClusterNode.add(new HostAndPort("127.0.0.1", 7379));
  final JedisCluster jc = new JedisCluster(jedisClusterNode, DEFAULT_TIMEOUT, DEFAULT_TIMEOUT, DEFAULT_REDIRECTIONS, "cluster", DEFAULT_CONFIG);
  jc.set("foo", "bar");

  ThreadPoolExecutor executor = new ThreadPoolExecutor(10, 100, 0, TimeUnit.SECONDS,
      new ArrayBlockingQueue<Runnable>(10));
  List<Future<String>> futures = new ArrayList<Future<String>>();
  for (int i = 0; i < 50; i++) {
    executor.submit(new Callable<String>() {
      @Override
      public String call() throws Exception {
        // FIXME : invalidate slot cache from JedisCluster to test
        // random connection also does work
        return jc.get("foo");
      }
    });
  }

  for (Future<String> future : futures) {
    String value = future.get();
    assertEquals("bar", value);
  }

  jc.close();
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:30,代碼來源:JedisClusterTest.java

示例6: get

import redis.clients.jedis.JedisCluster; //導入方法依賴的package包/類
public Object get(String cluster, String key) throws Exception {
	List<D_RedisClusterNode> nodes = clusterNodeService.getAllClusterNodes(cluster);
	Set<HostAndPort> masters = new HashSet<HostAndPort>();
	nodes.forEach(node->{
		masters.add(new HostAndPort(node.getHost(), node.getPort()));
	});
	Object value = null;
	JedisCluster jedis = new JedisCluster(masters);
	try {
		String type = jedis.type(key);
		switch (type) {
		case "string":
			value = jedis.get(key);
			break;
		case "list":
			value = jedis.lrange(key, 0, -1);
			break;
		case "set":
			value = jedis.smembers(key);
			break;
		case "zset":
			value = jedis.zrange(key, 0, -1);
			break;
		case "hash":
			value = jedis.hgetAll(key);
			break;
		default:
			break;
		}
	} finally {
		jedis.close();
	}
	return value;
}
 
開發者ID:yanfanvip,項目名稱:RedisClusterManager,代碼行數:35,代碼來源:QueryService.java

示例7: delete

import redis.clients.jedis.JedisCluster; //導入方法依賴的package包/類
public void delete(String cluster, String key) throws Exception {
	List<D_RedisClusterNode> nodes = clusterNodeService.getAllClusterNodes(cluster);
	Set<HostAndPort> masters = new HashSet<HostAndPort>();
	nodes.forEach(node->{
		masters.add(new HostAndPort(node.getHost(), node.getPort()));
	});
	JedisCluster jedis = new JedisCluster(masters);
	try {
		jedis.del(key);
	} finally {
		jedis.close();
	}
}
 
開發者ID:yanfanvip,項目名稱:RedisClusterManager,代碼行數:14,代碼來源:QueryService.java

示例8: foo3

import redis.clients.jedis.JedisCluster; //導入方法依賴的package包/類
@SuppressWarnings("unused")
private static void foo3() {

    System.out.println("TEST JedisCluster ======================================================");

    JedisCluster jc = new JedisCluster(new HostAndPort("127.0.0.1", 6380));
    jc.set("foo", "bar");
    String val = jc.get("foo");
    System.out.println(val);

    jc.set("foo1", "bar");
    jc.set("foo2", "bar");
    jc.set("foo3", "bar");
    jc.set("foo4", "bar");
    jc.set("foo5", "bar");

    jc.del("foo");
    jc.del("foo1");
    jc.del("foo2");
    jc.del("foo3");
    jc.del("foo4");
    jc.del("foo5");

    try {
        jc.close();
    }
    catch (IOException e) {
        e.printStackTrace();
    }
}
 
開發者ID:uavorg,項目名稱:uavstack,代碼行數:31,代碼來源:DoTestJedisHookProxy.java


注:本文中的redis.clients.jedis.JedisCluster.close方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。