T
T
Timur Evgazhukov2016-02-05 10:22:35
Redis
Timur Evgazhukov, 2016-02-05 10:22:35

How to set up a connection to Redis on jelastic via Spring?

I added Redis to my environment and the following data came to my mail: username, password, IP, host, port and sentinel port.
I'm confused to connect through JedisConnectionFactory, but nothing comes out. What am I doing wrong?
@Bean
public JedisConnectionFactory connectionFactory() {
JedisShardInfo shardInfo = new JedisShardInfo(HOST, USERNAME);
shardInfo.setPassword(PASSWORD);
RedisSentinelConfiguration sentinelConfiguration = new RedisSentinelConfiguration()
.master("mymaster")
.sentinel(HOST, PORT);
JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory(sentinelConfiguration);
jedisConnectionFactory.setShardInfo(shardInfo);
// jedisConnectionFactory.setHostName(HOST);
// jedisConnectionFactory.setPassword(PASSWORD);
return jedisConnectionFactory;
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
Timur Evgazhukov, 2016-03-03
@evgajukov

It turned out that the library did not support the installed version of Redis, as soon as I brought it into line, everything worked. Now I use the jedis library, it seemed to me the most convenient to use.

D
DKay, 2016-02-07
@DKay

Hello.
Are you debugging your code locally? Have you tried connecting to the Redis database using redis-cli?
If you are using a hostname rather than an IP address to connect, then you need to forward the port to the Redis container using this solution.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question