com.gitee.easyopen.session.ApiRedisTemplate Maven / Gradle / Ivy
package com.gitee.easyopen.session;
import org.springframework.data.redis.connection.DefaultStringRedisConnection;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
/**
* @author tanghc
*/
public class ApiRedisTemplate extends RedisTemplate {
public ApiRedisTemplate() {
RedisSerializer stringSerializer = new StringRedisSerializer();
setKeySerializer(stringSerializer);
setHashKeySerializer(stringSerializer);
}
public ApiRedisTemplate(RedisConnectionFactory connectionFactory) {
this();
setConnectionFactory(connectionFactory);
afterPropertiesSet();
}
@Override
protected RedisConnection preProcessConnection(RedisConnection connection, boolean existingConnection) {
return new DefaultStringRedisConnection(connection);
}
}