Example usage for org.springframework.data.redis.core RedisTemplate setExposeConnection

List of usage examples for org.springframework.data.redis.core RedisTemplate setExposeConnection

Introduction

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

Prototype

public void setExposeConnection(boolean exposeConnection) 

Source Link

Document

Sets whether to expose the Redis connection to RedisCallback code.

Usage

From source file:locksdemo.RedisUtils.java

static <K, V> RedisTemplate<K, V> createRedisTemplate(RedisConnectionFactory connectionFactory,
        Class<V> valueClass) {
    RedisTemplate<K, V> redisTemplate = new RedisTemplate<K, V>();
    redisTemplate.setKeySerializer(new StringRedisSerializer());
    redisTemplate.setValueSerializer(new GenericToStringSerializer<V>(valueClass));

    // avoids proxy
    redisTemplate.setExposeConnection(true);

    redisTemplate.setConnectionFactory(connectionFactory);
    redisTemplate.afterPropertiesSet();/*from w w  w  . j  av  a2  s.c  o  m*/
    return redisTemplate;
}