/** * String-focused extension of RedisTemplate. Since most operations against Redis are String based, this class provides * a dedicated class that minimizes configuration of its more generic {@link RedisTemplate template} especially in terms * of serializers. * <p/> * Note that this template exposes the {@link RedisConnection} used by the {@link RedisCallback} as a * {@link StringRedisConnection}. * * @author Costin Leau * @author Mark Paluch */ publicclassStringRedisTemplateextendsRedisTemplate<String, String> {
/** * Constructs a new <code>StringRedisTemplate</code> instance. {@link #setConnectionFactory(RedisConnectionFactory)} * and {@link #afterPropertiesSet()} still need to be called. */ publicStringRedisTemplate(){ setKeySerializer(RedisSerializer.string()); setValueSerializer(RedisSerializer.string()); setHashKeySerializer(RedisSerializer.string()); setHashValueSerializer(RedisSerializer.string()); }
/** * Constructs a new <code>StringRedisTemplate</code> instance ready to be used. * * @param connectionFactory connection factory for creating new connections */ publicStringRedisTemplate(RedisConnectionFactory connectionFactory){ this(); setConnectionFactory(connectionFactory); afterPropertiesSet(); }