本文整理汇总了Java中io.lettuce.core.RedisURI类的典型用法代码示例。如果您正苦于以下问题:Java RedisURI类的具体用法?Java RedisURI怎么用?Java RedisURI使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RedisURI类属于io.lettuce.core包,在下文中一共展示了RedisURI类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Database
import io.lettuce.core.RedisURI; //导入依赖的package包/类
public Database(String serverID, String hostname, String password, int port, int dbnumber) {
this.serverID = serverID;
RedisURI redisURI = RedisURI.builder()
.withHost(hostname)
.withPassword(password)
.withPort(port)
.withDatabase(dbnumber)
.withClientName("rmanager-" + serverID)
.build();
redisClient = RedisClient.create(redisURI);
syncCommands = redisClient.connect().sync();
new RedisMessenger(serverID, redisURI);
}
示例2: testSentinel
import io.lettuce.core.RedisURI; //导入依赖的package包/类
@Test
public void testSentinel() throws Exception {
RedisURI redisUri = RedisURI.Builder
.sentinel("127.0.0.1", 26379, "mymaster")
.withSentinel("127.0.0.1", 26380)
.withSentinel("127.0.0.1", 26381)
.build();
RedisClient client = RedisClient.create(redisUri);
test(client);
}
示例3: testCluster
import io.lettuce.core.RedisURI; //导入依赖的package包/类
@Test
public void testCluster() {
if (!RedisLettuceCacheTest.checkOS()) {
return;
}
RedisURI node1 = RedisURI.create("127.0.0.1", 7000);
RedisURI node2 = RedisURI.create("127.0.0.1", 7001);
RedisURI node3 = RedisURI.create("127.0.0.1", 7002);
RedisClusterClient client = RedisClusterClient.create(Arrays.asList(node1, node2, node3));
LettuceConnectionManager m = LettuceConnectionManager.defaultManager();
Assert.assertSame(m.commands(client), m.commands(client));
Assert.assertSame(m.asyncCommands(client), m.asyncCommands(client));
Assert.assertSame(m.reactiveCommands(client), m.reactiveCommands(client));
m.removeAndClose(client);
}
示例4: testCluster
import io.lettuce.core.RedisURI; //导入依赖的package包/类
@Test
public void testCluster() throws Exception {
if (!checkOS()) {
return;
}
RedisURI node1 = RedisURI.create("127.0.0.1", 7000);
RedisURI node2 = RedisURI.create("127.0.0.1", 7001);
RedisURI node3 = RedisURI.create("127.0.0.1", 7002);
RedisClusterClient client = RedisClusterClient.create(Arrays.asList(node1, node2, node3));
test(client);
}
示例5: initCache
import io.lettuce.core.RedisURI; //导入依赖的package包/类
@Override
protected CacheBuilder initCache(ConfigTree ct, String cacheAreaWithPrefix) {
Map<String, Object> map = ct.subTree("uri"/*there is no dot*/).getProperties();
AbstractRedisClient client = null;
if (map == null || map.size() == 0) {
throw new CacheConfigException("uri is required");
} else if (map.size() == 1) {
String uri = (String) map.values().iterator().next();
client = RedisClient.create(uri);
} else {
List<RedisURI> list = map.values().stream().map((k) -> RedisURI.create(URI.create(k.toString())))
.collect(Collectors.toList());
client = RedisClusterClient.create(list);
}
ExternalCacheBuilder externalCacheBuilder = RedisLettuceCacheBuilder.createRedisLettuceCacheBuilder()
.redisClient(client);
parseGeneralConfig(externalCacheBuilder, ct);
// eg: "remote.default.client"
autoConfigureBeans.getCustomContainer().put(cacheAreaWithPrefix + ".client", client);
LettuceConnectionManager m = LettuceConnectionManager.defaultManager();
autoConfigureBeans.getCustomContainer().put(cacheAreaWithPrefix + ".connection", m.connection(client));
autoConfigureBeans.getCustomContainer().put(cacheAreaWithPrefix + ".commands", m.commands(client));
autoConfigureBeans.getCustomContainer().put(cacheAreaWithPrefix + ".asyncCommands", m.asyncCommands(client));
autoConfigureBeans.getCustomContainer().put(cacheAreaWithPrefix + ".reactiveCommands", m.reactiveCommands(client));
return externalCacheBuilder;
}