Java Code Examples for io.lettuce.core.RedisURI#create()

The following examples show how to use io.lettuce.core.RedisURI#create() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LettuceConnectionManagerTest.java    From jetcache with Apache License 2.0 6 votes vote down vote up
@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();
    m.init(client, null);
    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);
}
 
Example 2
Source File: RedisLettuceCacheTest.java    From jetcache with Apache License 2.0 6 votes vote down vote up
@Test
public void testCluster2() 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));
    StatefulRedisClusterConnection con = client.connect(new JetCacheCodec());
    con.setReadFrom(ReadFrom.SLAVE_PREFERRED);
    cache = RedisLettuceCacheBuilder.createRedisLettuceCacheBuilder()
            .redisClient(client)
            .connection(con)
            .keyPrefix(new Random().nextInt() + "")
            .buildCache();
    cache.put("K1", "V1");
    Thread.sleep(100);
    Assert.assertEquals("V1", cache.get("K1"));
}
 
Example 3
Source File: RedisSinkTest.java    From hazelcast-jet-contrib with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
    client = container.newRedisClient();
    connection = client.connect();
    uri = RedisURI.create(container.connectionString());

    instance = createJetMember();
}
 
Example 4
Source File: RedisSourceTest.java    From hazelcast-jet-contrib with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
    client = container.newRedisClient();
    connection = client.connect();
    uri = RedisURI.create(container.connectionString());

    instance = createJetMember();
    instanceToShutDown = createJetMember();
}
 
Example 5
Source File: RedisBackedJobService.java    From feast with Apache License 2.0 5 votes vote down vote up
public RedisBackedJobService(FeastProperties.JobStoreProperties jobStoreProperties) {
  RedisURI uri =
      RedisURI.create(jobStoreProperties.getRedisHost(), jobStoreProperties.getRedisPort());

  this.syncCommand =
      RedisClient.create(DefaultClientResources.create(), uri)
          .connect(new ByteArrayCodec())
          .sync();
}
 
Example 6
Source File: RedisLettuceCacheTest.java    From jetcache with Apache License 2.0 5 votes vote down vote up
@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,null);
}
 
Example 7
Source File: RedisCacheImpl.java    From openbd-core with GNU General Public License v3.0 5 votes vote down vote up
private void connectToMasterSlave(String[] servers) {
			
       redisClient = RedisClient.create();

       List<RedisURI> nodes = new ArrayList<>();
       for(String s: servers) {
       	RedisURI sRedisURI = RedisURI.create(s);
       	nodes.add(sRedisURI);
       }

       StatefulRedisMasterSlaveConnection<String, String> connection = MasterSlave
               .connect(redisClient, new Utf8StringCodec(), nodes);
       connection.setReadFrom(ReadFrom.MASTER_PREFERRED);
	
}