public class RedisSentinel extends Redis
| Constructor and Description |
|---|
RedisSentinel() |
| Modifier and Type | Method and Description |
|---|---|
void |
configure(Env env,
com.typesafe.config.Config config,
com.google.inject.Binder binder)
Creates a new
RedisSentinel instance and connect to the provided database. |
public void configure(Env env, com.typesafe.config.Config config, com.google.inject.Binder binder)
Creates a new RedisSentinel instance and connect to the provided database. Please note, the
name is a property in your application.conf file with Redis URI.
RedisSentinel is pool of Jedis and for get Jedis just call pool.getResource()
{
use(new RedisSentinel("db1"));
}
application.conf
jedis.sentinel.hosts = ["localhost:26379", "host2:26379"] jedis.sentinel.master = "master" jedis.password = "mySuperSecretPasswordPutHere"Example:
try (Jedis redis = request.require(JedisSentinelPool.class).getResource()) {
System.out.println( redis.set("test", "this is work") );
System.out.println( redis.get("test");
} catch (Exception e) {
e.printStackTrace();
}
configure in interface Jooby.Moduleconfigure in class RedisCopyright © 2021. All rights reserved.