Example usage for org.springframework.data.redis.core RedisConnectionUtils getConnection

List of usage examples for org.springframework.data.redis.core RedisConnectionUtils getConnection

Introduction

In this page you can find the example usage for org.springframework.data.redis.core RedisConnectionUtils getConnection.

Prototype

public static RedisConnection getConnection(RedisConnectionFactory factory) 

Source Link

Document

Gets a Redis connection from the given factory.

Usage

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

@Override
protected void doHealthCheck(Health.Builder builder) throws Exception {
    if (valid) {/*from  w  ww.  jav  a2 s  . com*/
        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();
    }
}