当前位置: 首页>>代码示例>>Java>>正文


Java ShardedJedisPipeline.syncAndReturnAll方法代码示例

本文整理汇总了Java中redis.clients.jedis.ShardedJedisPipeline.syncAndReturnAll方法的典型用法代码示例。如果您正苦于以下问题:Java ShardedJedisPipeline.syncAndReturnAll方法的具体用法?Java ShardedJedisPipeline.syncAndReturnAll怎么用?Java ShardedJedisPipeline.syncAndReturnAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在redis.clients.jedis.ShardedJedisPipeline的用法示例。


在下文中一共展示了ShardedJedisPipeline.syncAndReturnAll方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testSyncWithNoCommandQueued

import redis.clients.jedis.ShardedJedisPipeline; //导入方法依赖的package包/类
@Test
public void testSyncWithNoCommandQueued() {
  JedisShardInfo shardInfo1 = new JedisShardInfo(redis1.getHost(), redis1.getPort());
  JedisShardInfo shardInfo2 = new JedisShardInfo(redis2.getHost(), redis2.getPort());
  shardInfo1.setPassword("foobared");
  shardInfo2.setPassword("foobared");
  List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>();
  shards.add(shardInfo1);
  shards.add(shardInfo2);

  ShardedJedis jedis2 = new ShardedJedis(shards);

  ShardedJedisPipeline pipeline = jedis2.pipelined();
  pipeline.sync();

  jedis2.close();

  jedis2 = new ShardedJedis(shards);
  pipeline = jedis2.pipelined();
  List<Object> resp = pipeline.syncAndReturnAll();
  assertTrue(resp.isEmpty());

  jedis2.close();
}
 
开发者ID:sohutv,项目名称:cachecloud,代码行数:25,代码来源:ShardedJedisPipelineTest.java

示例2: testShardPipelined

import redis.clients.jedis.ShardedJedisPipeline; //导入方法依赖的package包/类
public void testShardPipelined() {// 0.127秒
	JedisShardInfo jedis = new JedisShardInfo("120.25.241.144", 6379);
	jedis.setPassword("b840fc02d52404542994");

	List<JedisShardInfo> shards = Arrays.asList(jedis);
	ShardedJedis sharding = new ShardedJedis(shards);
	ShardedJedisPipeline pipeline = sharding.pipelined();

	long start = System.currentTimeMillis();
	for (int i = 0; i < 1000; i++) {
		pipeline.set("n" + i, "n" + i);
		System.out.println(i);
	}
	pipeline.syncAndReturnAll();
	long end = System.currentTimeMillis();
	System.out.println("共花费:" + (end - start) / 1000.0 + "秒");

	sharding.disconnect();
	try {
		Closeables.close(sharding, true);
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:xiangxik,项目名称:java-platform,代码行数:25,代码来源:RedisExample.java

示例3: testShardpipelined

import redis.clients.jedis.ShardedJedisPipeline; //导入方法依赖的package包/类
/**
 * 分布式直连异步调用
 * 耗时:
 * 0.866 seconds
 * 0.892 seconds
 */
@Test
@Ignore
public void testShardpipelined() {
    List<JedisShardInfo> shards = Arrays.asList(
            new JedisShardInfo("localhost",6379),
            new JedisShardInfo("localhost",6379));

    ShardedJedis sharding = new ShardedJedis(shards);

    ShardedJedisPipeline pipeline = sharding.pipelined();
    long start = System.currentTimeMillis();
    for (int i = 0; i < 100000; i++) {
        pipeline.set("sp" + i, "p" + i);
    }
    List<Object> results = pipeline.syncAndReturnAll();
    long end = System.currentTimeMillis();
    System.out.println("[email protected] SET: " + ((end - start)/1000.0) + " seconds");

    sharding.disconnect();
    sharding.close();
}
 
开发者ID:leopardoooo,项目名称:easyooo-framework,代码行数:28,代码来源:JedisApiTest.java

示例4: testShardPipelinedPool

import redis.clients.jedis.ShardedJedisPipeline; //导入方法依赖的package包/类
/**
 * 分布式连接池异步调用
 * 0.452 seconds
 * 0.43 seconds
 */
@Test
@Ignore
public void testShardPipelinedPool() {
    List<JedisShardInfo> shards = Arrays.asList(
            new JedisShardInfo("localhost",6379),
            new JedisShardInfo("localhost",6379));

    ShardedJedisPool pool = new ShardedJedisPool(new JedisPoolConfig(), shards);
    ShardedJedis one = pool.getResource();
    ShardedJedisPipeline pipeline = one.pipelined();
    
    long start = System.currentTimeMillis();
    for (int i = 0; i < COUNTER; i++) {
        pipeline.set("sppn" + i, "n" + i);
    }
    List<Object> results = pipeline.syncAndReturnAll();
    long end = System.currentTimeMillis();
    pool.returnResource(one);
    logger.info("[email protected] SET: " + ((end - start)/1000.0) + " seconds");
    pool.destroy();
}
 
开发者ID:leopardoooo,项目名称:easyooo-framework,代码行数:27,代码来源:JedisApiTest.java

示例5: returnResourceShouldResetState

import redis.clients.jedis.ShardedJedisPipeline; //导入方法依赖的package包/类
@Test
public void returnResourceShouldResetState() throws URISyntaxException {
  GenericObjectPoolConfig config = new GenericObjectPoolConfig();
  config.setMaxTotal(1);
  config.setBlockWhenExhausted(false);

  List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>();
  shards.add(new JedisShardInfo(new URI("redis://:[email protected]:6380")));
  shards.add(new JedisShardInfo(new URI("redis://:[email protected]:6379")));

  ShardedJedisPool pool = new ShardedJedisPool(config, shards);

  ShardedJedis jedis = pool.getResource();
  jedis.set("pipelined", String.valueOf(0));
  jedis.set("pipelined2", String.valueOf(0));

  ShardedJedisPipeline pipeline = jedis.pipelined();

  pipeline.incr("pipelined");
  pipeline.incr("pipelined2");

  jedis.resetState();

  pipeline = jedis.pipelined();
  pipeline.incr("pipelined");
  pipeline.incr("pipelined2");
  List<Object> results = pipeline.syncAndReturnAll();

  assertEquals(2, results.size());
  pool.returnResource(jedis);
  pool.destroy();
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:33,代码来源:ShardedJedisPoolTest.java

示例6: pipeline

import redis.clients.jedis.ShardedJedisPipeline; //导入方法依赖的package包/类
@Test
public void pipeline() throws UnsupportedEncodingException {
  ShardedJedisPipeline p = jedis.pipelined();
  p.set("foo", "bar");
  p.get("foo");
  List<Object> results = p.syncAndReturnAll();

  assertEquals(2, results.size());
  assertEquals("OK", results.get(0));
  assertEquals("bar", results.get(1));
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:12,代码来源:ShardedJedisPipelineTest.java

示例7: pAddSet

import redis.clients.jedis.ShardedJedisPipeline; //导入方法依赖的package包/类
public List<Object> pAddSet(String key, int seconds, String... values) {
    try (ShardedJedis shardedJedis = shardedJedisPool.getResource()) {
        ShardedJedisPipeline pipeline = shardedJedis.pipelined();
        for(String value : values) {
            pipeline.sadd(key, value);
        }
        pipeline.expire(key, seconds);
        List<Object> result = pipeline.syncAndReturnAll();
        result.remove(result.size() -1);
        return result;
    }
}
 
开发者ID:jigsaw-projects,项目名称:jigsaw-payment,代码行数:13,代码来源:RedisTemplate.java

示例8: returnResourceShouldResetState

import redis.clients.jedis.ShardedJedisPipeline; //导入方法依赖的package包/类
@Test
public void returnResourceShouldResetState() throws URISyntaxException {
  GenericObjectPoolConfig config = new GenericObjectPoolConfig();
  config.setMaxTotal(1);
  config.setBlockWhenExhausted(false);

  List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>();
  shards.add(new JedisShardInfo(new URI("redis://:[email protected]:6380")));
  shards.add(new JedisShardInfo(new URI("redis://:[email protected]:6379")));

  ShardedJedisPool pool = new ShardedJedisPool(config, shards);

  ShardedJedis jedis = pool.getResource();
  jedis.set("pipelined", String.valueOf(0));
  jedis.set("pipelined2", String.valueOf(0));

  ShardedJedisPipeline pipeline = jedis.pipelined();

  pipeline.incr("pipelined");
  pipeline.incr("pipelined2");

  jedis.resetState();

  pipeline = jedis.pipelined();
  pipeline.incr("pipelined");
  pipeline.incr("pipelined2");
  List<Object> results = pipeline.syncAndReturnAll();

  assertEquals(2, results.size());
  jedis.close();
  pool.destroy();
}
 
开发者ID:sohutv,项目名称:cachecloud,代码行数:33,代码来源:ShardedJedisPoolTest.java

示例9: testShardPipelinnedPool

import redis.clients.jedis.ShardedJedisPipeline; //导入方法依赖的package包/类
public void testShardPipelinnedPool() {// 0.124秒
	JedisShardInfo jedis = new JedisShardInfo("120.25.241.144", 6379);
	jedis.setPassword("b840fc02d52404542994");

	List<JedisShardInfo> shards = Arrays.asList(jedis);
	ShardedJedisPool pool = new ShardedJedisPool(new JedisPoolConfig(), shards);

	ShardedJedis sharding = pool.getResource();
	ShardedJedisPipeline pipeline = sharding.pipelined();

	long start = System.currentTimeMillis();
	for (int i = 0; i < 1000; i++) {
		pipeline.set("n" + i, "n" + i);
		System.out.println(i);
	}
	pipeline.syncAndReturnAll();
	long end = System.currentTimeMillis();
	System.out.println("共花费:" + (end - start) / 1000.0 + "秒");

	sharding.disconnect();
	pool.destroy();

	try {
		Closeables.close(sharding, true);
		Closeables.close(pool, true);
	} catch (IOException e) {
		e.printStackTrace();
	}

}
 
开发者ID:xiangxik,项目名称:java-platform,代码行数:31,代码来源:RedisExample.java

示例10: test6shardpipelined

import redis.clients.jedis.ShardedJedisPipeline; //导入方法依赖的package包/类
@Test
public void test6shardpipelined() {
	ShardedJedisPipeline pipeline = sharding.pipelined();
	long start = System.currentTimeMillis();
	for (int i = 0; i < 100000; i++) {
		pipeline.set("sp" + i, "p" + i);
	}
	List<Object> results = pipeline.syncAndReturnAll();
	long end = System.currentTimeMillis();
	System.out.println("[email protected] SET: " + ((end - start) / 1000.0) + " seconds");
}
 
开发者ID:dreajay,项目名称:jcode,代码行数:12,代码来源:TestJedis.java

示例11: test8shardPipelinedPool

import redis.clients.jedis.ShardedJedisPipeline; //导入方法依赖的package包/类
@Test
public void test8shardPipelinedPool() {
	ShardedJedis one = pool.getResource();

	ShardedJedisPipeline pipeline = one.pipelined();

	long start = System.currentTimeMillis();
	for (int i = 0; i < 100000; i++) {
		pipeline.set("sppn" + i, "n" + i);
	}
	List<Object> results = pipeline.syncAndReturnAll();
	long end = System.currentTimeMillis();
	pool.returnResource(one);
	System.out.println("[email protected] SET: " + ((end - start) / 1000.0) + " seconds");
}
 
开发者ID:dreajay,项目名称:jcode,代码行数:16,代码来源:TestJedis.java


注:本文中的redis.clients.jedis.ShardedJedisPipeline.syncAndReturnAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。