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


Java RedisURI类代码示例

本文整理汇总了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);
}
 
开发者ID:RedEpicness,项目名称:RManager,代码行数:18,代码来源:Database.java

示例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);
}
 
开发者ID:alibaba,项目名称:jetcache,代码行数:11,代码来源:RedisLettuceCacheTest.java

示例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);
}
 
开发者ID:alibaba,项目名称:jetcache,代码行数:16,代码来源:LettuceConnectionManagerTest.java

示例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);
}
 
开发者ID:alibaba,项目名称:jetcache,代码行数:12,代码来源:RedisLettuceCacheTest.java

示例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;
}
 
开发者ID:alibaba,项目名称:jetcache,代码行数:29,代码来源:RedisLettuceAutoConfiguration.java


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