Example usage for org.springframework.data.redis.connection.jedis JedisConnectionFactory getDatabase

List of usage examples for org.springframework.data.redis.connection.jedis JedisConnectionFactory getDatabase

Introduction

In this page you can find the example usage for org.springframework.data.redis.connection.jedis JedisConnectionFactory getDatabase.

Prototype

public int getDatabase() 

Source Link

Document

Returns the index of the database.

Usage

From source file:com.snowstore.mercury.indicator.RedisHealthIndicator.java

@Override
protected void doHealthCheck(Health.Builder builder) throws Exception {
    if (valid) {// w w w.ja  v a  2  s  .co m
        RedisConnection connection = RedisConnectionUtils.getConnection(this.redisConnectionFactory);
        try {
            Properties info = connection.info();
            builder.up().withDetail("version", info.getProperty("redis_version"));
            if (redisConnectionFactory instanceof JedisConnectionFactory) {
                JedisConnectionFactory jedisConnectionFactory = (JedisConnectionFactory) redisConnectionFactory;
                builder.withDetail(SERVER, jedisConnectionFactory.getHostName() + ":"
                        + jedisConnectionFactory.getPort() + ":" + jedisConnectionFactory.getDatabase());
            }
            addBuilder(builder);
        } finally {
            RedisConnectionUtils.releaseConnection(connection, this.redisConnectionFactory);
        }
    } else {
        builder.none();
    }
}