当前位置: 首页>>代码示例>>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;未经允许,请勿转载。