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


Java RedisClient.create方法代码示例

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


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

示例1: testAuth

import io.vertx.redis.RedisClient; //导入方法依赖的package包/类
@Test
//Note the try/finally is to ensure that the server is shutdown so other tests do not have to
//provide auth information
public void testAuth() throws Exception {

  RedisServer server = RedisServer.builder().port(6381).setting("requirepass foobar").build();
  server.start();
  RedisOptions job = new RedisOptions()
    .setHost("localhost")
    .setPort(6381);
  RedisClient rdx = RedisClient.create(vertx, job);

  rdx.auth("barfoo", reply -> {
    assertFalse(reply.succeeded());
    rdx.auth("foobar", reply2 -> {
      assertTrue(reply2.succeeded());
      try {
        server.stop();
      } catch (Exception ignore) {
      }
      testComplete();
    });
  });
  await();
}
 
开发者ID:vert-x3,项目名称:vertx-redis-client,代码行数:26,代码来源:RedisClientTestBase.java

示例2: initData

import io.vertx.redis.RedisClient; //导入方法依赖的package包/类
/**
 * Init the redis client and save sample data
 */
private void initData() {
    RedisOptions config;
    // this is for OpenShift Redis Cartridge
    String osPort = System.getenv("OPENSHIFT_REDIS_PORT");
    String osHost = System.getenv("OPENSHIFT_REDIS_HOST");
    if (osPort != null && osHost != null)
        config = new RedisOptions()
            .setHost(osHost).setPort(Integer.parseInt(osPort));
    else
        config = new RedisOptions().setHost(HOST);

    redis = RedisClient.create(vertx, config);

    redis.hset(REDIS_TODO_KEY, "98", Json.encodePrettily(
            new Todo(98, "Something to do...", false, 1, "todo/ex")), res -> {
        if (res.failed()) {
            System.err.println("[Error]Redis service is not running!");
            res.cause().printStackTrace();
        }
    });

}
 
开发者ID:sczyh30,项目名称:todo-backend-vert.x,代码行数:26,代码来源:TodoVerticle.java

示例3: start

import io.vertx.redis.RedisClient; //导入方法依赖的package包/类
@Override
public void start(Future<Void> future) {
	mongo = new MongoDAO(MongoClient.createShared(vertx, config.getJsonObject("mongo")));
	RedisDAO redis = new RedisDAO(RedisClient.create(vertx, RedisUtils.createRedisOptions(config.getJsonObject("redis"))));
	authApi = new AuthenticationApi(mongo);
	feedsApi = new FeedsApi(mongo, redis);
	server = vertx.createHttpServer(createOptions());
	server.requestHandler(createRouter()::accept);
	server.listen(result -> {
		if (result.succeeded()) {
			future.complete();
		} else {
			future.fail(result.cause());
		}
	});
}
 
开发者ID:aesteve,项目名称:vertx-feeds,代码行数:17,代码来源:WebServer.java

示例4: example3

import io.vertx.redis.RedisClient; //导入方法依赖的package包/类
public void example3(Vertx vertx) {

    // register a handler for the incoming message the naming the Redis module will use is base address + '.' + redis channel
    vertx.eventBus().<JsonObject>consumer("io.vertx.redis.channel1", received -> {
      // do whatever you need to do with your message
      JsonObject value = received.body().getJsonObject("value");
      // the value is a JSON doc with the following properties
      // channel - The channel to which this message was sent
      // pattern - Pattern is present if you use psubscribe command and is the pattern that matched this message channel
      // message - The message payload
    });

    RedisClient redis = RedisClient.create(vertx, new RedisOptions());

    redis.subscribe("channel1", res -> {
      if (res.succeeded()) {
        // so something...
      }
    });
  }
 
开发者ID:vert-x3,项目名称:vertx-redis-client,代码行数:21,代码来源:Examples.java

示例5: testDebugSegfault

import io.vertx.redis.RedisClient; //导入方法依赖的package包/类
@Test
public void testDebugSegfault() throws Exception {

  RedisServer server = RedisServer.builder().port(6381).build();
  server.start();
  RedisOptions job = new RedisOptions()
    .setHost("localhost")
    .setPort(6381);
  RedisClient rdx = RedisClient.create(vertx, job);

  rdx.debugSegfault(reply -> {
    // this should fail, since we crashed the server on purpose
    assertTrue(reply.failed());
    rdx.info(reply2 -> {
      assertFalse(reply2.succeeded());
      server.stop();
      testComplete();
    });
  });
  await();
}
 
开发者ID:vert-x3,项目名称:vertx-redis-client,代码行数:22,代码来源:RedisClientTestBase.java

示例6: testScriptkill

import io.vertx.redis.RedisClient; //导入方法依赖的package包/类
@Test
public void testScriptkill() throws Exception {

  String inline = "while true do end";
  redis.eval(inline, Collections.emptyList(), Collections.emptyList(), reply -> {
    //server should be locked at this point
  });

  RedisOptions job = new RedisOptions()
    .setHost("localhost")
    .setPort(6379);
  RedisClient rdx = RedisClient.create(vertx, job);

  rdx.scriptKill(reply -> {
    assertTrue(reply.succeeded());
    rdx.info(reply2 -> {
      assertTrue(reply2.succeeded());
      testComplete();
    });
  });
  await();
}
 
开发者ID:vert-x3,项目名称:vertx-redis-client,代码行数:23,代码来源:RedisClientTestBase.java

示例7: init

import io.vertx.redis.RedisClient; //导入方法依赖的package包/类
public static void init(Vertx vertx) throws InterruptedException {
  RedisOptions redisOptions = new RedisOptions()
      .setHost(PerfConfiguration.redisHost)
      .setPort(PerfConfiguration.redisPort)
      .setAuth(PerfConfiguration.redisPassword);
  ClientPoolFactory<RedisClient> factory = () -> {
    return RedisClient.create(vertx, redisOptions);
  };
  clientMgr = new ClientPoolManager<>(vertx, factory);

  DeploymentOptions deployOptions = VertxUtils.createClientDeployOptions(clientMgr,
      PerfConfiguration.redisClientCount);
  VertxUtils.blockDeploy(vertx, ClientVerticle.class, deployOptions);
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:15,代码来源:RedisClientUtils.java

示例8: getRedisClient

import io.vertx.redis.RedisClient; //导入方法依赖的package包/类
private RedisClient getRedisClient() {
	if (this.redisClient == null) {
		final DedupConfig ddConfig = this.getDedupConfig();
		final RedisOptions redisOptions = new RedisOptions();	
		redisOptions.setAddress(ddConfig.getServerURL());
		redisOptions.setAuth(ddConfig.getSfdcPassword());
		if (ddConfig.getPort() > 0) {
			redisOptions.setPort(ddConfig.getPort());
		}
		
		this.redisClient = RedisClient.create(this.getVertx(), redisOptions);
	}
	return this.redisClient;
}
 
开发者ID:Stwissel,项目名称:vertx-sfdc-platformevents,代码行数:15,代码来源:RedisDedup.java

示例9: createRedisClient

import io.vertx.redis.RedisClient; //导入方法依赖的package包/类
@Produces
@RedisInstance
@ApplicationScoped
public RedisClient createRedisClient() {
    RedisOptions config = new RedisOptions().setHost("192.168.2.108");
    //RedisOptions config = new RedisOptions().setHost("192.168.56.2");
    return RedisClient.create(vertx, config);
}
 
开发者ID:bpark,项目名称:chlorophytum-semantics,代码行数:9,代码来源:VertxLauncher.java

示例10: getInstance

import io.vertx.redis.RedisClient; //导入方法依赖的package包/类
private RedisClient getInstance() {
    if (redis == null) {
        synchronized (RedisClient.class) {
            RedisOptions config = new RedisOptions()
                    .setHost(ninjaProperties.get(HOST_KEY))
                    .setPort(ninjaProperties.getInteger(PORT_KEY));
            redis = RedisClient.create(vertx, config);
        }
    }
    return redis;
}
 
开发者ID:kuangcao,项目名称:ninja-vertx-standalone,代码行数:12,代码来源:PubSub.java

示例11: retrieve

import io.vertx.redis.RedisClient; //导入方法依赖的package包/类
/**
 * Creates a Redis client for the service.
 *
 * @return the Redis client, configured to access the service
 */
@Override
protected RedisClient retrieve() {
  JsonObject result = record().getMetadata().copy();
  result.mergeIn(record().getLocation());

  if (config != null) {
    result.mergeIn(config);
  }

  return RedisClient.create(vertx, new RedisOptions(result));
}
 
开发者ID:vert-x3,项目名称:vertx-service-discovery,代码行数:17,代码来源:RedisDataSourceImpl.java

示例12: setUp

import io.vertx.redis.RedisClient; //导入方法依赖的package包/类
@Before
public void setUp(TestContext tc) throws IOException {
  vertx = Vertx.vertx();
  vertx.exceptionHandler(tc.exceptionHandler());

  redisServer = new RedisServer(6379);
  redisServer.start();

  testRedisClient = RedisClient.create(vertx,
      new RedisOptions().setHost("localhost").setPort(6379));
}
 
开发者ID:cescoffier,项目名称:vertx-configuration-service,代码行数:12,代码来源:RedisConfigurationStoreTest.java

示例13: getRedisClient

import io.vertx.redis.RedisClient; //导入方法依赖的package包/类
public RedisClient getRedisClient() {

        if (redisClient == null) {
            redisClient = RedisClient.create(getVertx(), getRedisOptions());

        }
        return redisClient;
    }
 
开发者ID:advantageous,项目名称:qbit-extensions,代码行数:9,代码来源:RedisKeyValueStoreBuilder.java

示例14: start

import io.vertx.redis.RedisClient; //导入方法依赖的package包/类
@Override
public void start(Future<Void> future) {
	mongo = MongoClient.createShared(vertx, config.getJsonObject("mongo"));
	redis = new RedisDAO(RedisClient.create(vertx, RedisUtils.createRedisOptions(config.getJsonObject("redis"))));
	fetchFeeds();
	future.complete();
}
 
开发者ID:aesteve,项目名称:vertx-feeds,代码行数:8,代码来源:FeedBroker.java

示例15: example2

import io.vertx.redis.RedisClient; //导入方法依赖的package包/类
public void example2(Vertx vertx) {
  RedisClient redis = RedisClient.create(vertx, new RedisOptions());

  redis.get("mykey", res -> {
    if (res.succeeded()) {
      // so something...
    }
  });
}
 
开发者ID:vert-x3,项目名称:vertx-redis-client,代码行数:10,代码来源:Examples.java


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