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

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

Introduction

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

Prototype

public void setKeySerializer(RedisSerializer<?> serializer) 

Source Link

Document

Sets the key serializer to be used by this template.

Usage

From source file:org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration.java

private RedisTemplate<Object, Object> createRedisTemplate() {
    RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>();
    redisTemplate.setKeySerializer(new StringRedisSerializer());
    redisTemplate.setHashKeySerializer(new StringRedisSerializer());
    if (this.defaultRedisSerializer != null) {
        redisTemplate.setDefaultSerializer(this.defaultRedisSerializer);
    }//  w w  w . j av a  2  s .  com
    redisTemplate.setConnectionFactory(this.redisConnectionFactory);
    redisTemplate.setBeanClassLoader(this.classLoader);
    redisTemplate.afterPropertiesSet();
    return redisTemplate;
}

From source file:org.springframework.session.data.redis.RedisOperationsSessionRepository.java

private static RedisTemplate<Object, Object> createDefaultTemplate(RedisConnectionFactory connectionFactory) {
    Assert.notNull(connectionFactory, "connectionFactory cannot be null");
    RedisTemplate<Object, Object> template = new RedisTemplate<Object, Object>();
    template.setKeySerializer(new StringRedisSerializer());
    template.setHashKeySerializer(new StringRedisSerializer());
    template.setConnectionFactory(connectionFactory);
    template.afterPropertiesSet();//from   ww w  . j  a v  a  2 s .co  m
    return template;
}