package org.hsweb.concureent.cache.redis; 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 zhouhao * @TODO */ public class FastJsonRedisTemplate extends RedisTemplate<String, Object> { /** * Constructs a new <code>StringRedisTemplate</code> instance. {@link #setConnectionFactory(RedisConnectionFactory)} * and {@link #afterPropertiesSet()} still need to be called. */ public FastJsonRedisTemplate() { RedisSerializer<String> stringSerializer = new StringRedisSerializer(); FastJsonRedisSerializer redisSerializer = new FastJsonRedisSerializer(); setKeySerializer(stringSerializer); setValueSerializer(redisSerializer); setHashKeySerializer(stringSerializer); setHashValueSerializer(redisSerializer); } /** * Constructs a new <code>StringRedisTemplate</code> instance ready to be used. * * @param connectionFactory connection factory for creating new connections */ public FastJsonRedisTemplate(RedisConnectionFactory connectionFactory) { this(); setConnectionFactory(connectionFactory); afterPropertiesSet(); } protected RedisConnection preProcessConnection(RedisConnection connection, boolean existingConnection) { return new DefaultStringRedisConnection(connection); } }