Java Code Examples for org.springframework.data.redis.core.StringRedisTemplate#setHashValueSerializer()
The following examples show how to use
org.springframework.data.redis.core.StringRedisTemplate#setHashValueSerializer() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RedisCacheConfig.java From ZTuoExchange_framework with MIT License | 6 votes |
/** * RedisTemplate配置 * @param factory * @return */ @Bean public RedisTemplate<String, String> redisTemplate(RedisConnectionFactory factory) { StringRedisTemplate template = new StringRedisTemplate(factory); //定义key序列化方式 //RedisSerializer<String> redisSerializer = new StringRedisSerializer();//Long类型会出现异常信息;需要我们上面的自定义key生成策略,一般没必要 //定义value的序列化方式 Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class); ObjectMapper om = new ObjectMapper(); om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); jackson2JsonRedisSerializer.setObjectMapper(om); // template.setKeySerializer(redisSerializer); template.setValueSerializer(jackson2JsonRedisSerializer); template.setHashValueSerializer(jackson2JsonRedisSerializer); template.afterPropertiesSet(); return template; }
Example 2
Source File: RedisCacheConfig.java From ZTuoExchange_framework with MIT License | 6 votes |
/** * RedisTemplate配置 * @param factory * @return */ @Bean public RedisTemplate<String, String> redisTemplate(RedisConnectionFactory factory) { StringRedisTemplate template = new StringRedisTemplate(factory); //定义key序列化方式 //RedisSerializer<String> redisSerializer = new StringRedisSerializer();//Long类型会出现异常信息;需要我们上面的自定义key生成策略,一般没必要 //定义value的序列化方式 Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class); ObjectMapper om = new ObjectMapper(); om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); jackson2JsonRedisSerializer.setObjectMapper(om); // template.setKeySerializer(redisSerializer); template.setValueSerializer(jackson2JsonRedisSerializer); template.setHashValueSerializer(jackson2JsonRedisSerializer); template.afterPropertiesSet(); return template; }
Example 3
Source File: RedisCacheConfig.java From ZTuoExchange_framework with MIT License | 6 votes |
/** * RedisTemplate配置 * @param factory * @return */ @Bean public RedisTemplate<String, String> redisTemplate(RedisConnectionFactory factory) { StringRedisTemplate template = new StringRedisTemplate(factory); //定义key序列化方式 //RedisSerializer<String> redisSerializer = new StringRedisSerializer();//Long类型会出现异常信息;需要我们上面的自定义key生成策略,一般没必要 //定义value的序列化方式 Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class); ObjectMapper om = new ObjectMapper(); om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); jackson2JsonRedisSerializer.setObjectMapper(om); // template.setKeySerializer(redisSerializer); template.setValueSerializer(jackson2JsonRedisSerializer); template.setHashValueSerializer(jackson2JsonRedisSerializer); template.afterPropertiesSet(); return template; }
Example 4
Source File: RedisCacheConfig.java From ZTuoExchange_framework with MIT License | 6 votes |
/** * RedisTemplate配置 * @param factory * @return */ @Bean public RedisTemplate<String, String> redisTemplate(RedisConnectionFactory factory) { StringRedisTemplate template = new StringRedisTemplate(factory); //定义key序列化方式 //RedisSerializer<String> redisSerializer = new StringRedisSerializer();//Long类型会出现异常信息;需要我们上面的自定义key生成策略,一般没必要 //定义value的序列化方式 Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class); ObjectMapper om = new ObjectMapper(); om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); jackson2JsonRedisSerializer.setObjectMapper(om); // template.setKeySerializer(redisSerializer); template.setValueSerializer(jackson2JsonRedisSerializer); template.setHashValueSerializer(jackson2JsonRedisSerializer); template.afterPropertiesSet(); return template; }
Example 5
Source File: RedisConfigure.java From cms with Apache License 2.0 | 6 votes |
/** * retemplate相关配置 * * @param factory * @return */ @Bean public StringRedisTemplate stringRedisTemplate(RedisConnectionFactory factory) { StringRedisTemplate template = new StringRedisTemplate(); // 配置连接工厂 template.setConnectionFactory(factory); //使用StringRedisSerializer来序列化和反序列化redis的key值 template.setKeySerializer(stringSerializer()); // 值采用json序列化 template.setValueSerializer(jackson2JsonRedisSerializer()); // 设置hash key 和value序列化模式 template.setHashKeySerializer(stringSerializer()); template.setHashValueSerializer(jackson2JsonRedisSerializer()); template.afterPropertiesSet(); return template; }
Example 6
Source File: RedisCacheConfig.java From ZTuoExchange_framework with MIT License | 6 votes |
/** * RedisTemplate配置 * @param factory * @return */ @Bean public RedisTemplate<String, String> redisTemplate(RedisConnectionFactory factory) { StringRedisTemplate template = new StringRedisTemplate(factory); //定义key序列化方式 //RedisSerializer<String> redisSerializer = new StringRedisSerializer();//Long类型会出现异常信息;需要我们上面的自定义key生成策略,一般没必要 //定义value的序列化方式 Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class); ObjectMapper om = new ObjectMapper(); om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); jackson2JsonRedisSerializer.setObjectMapper(om); // template.setKeySerializer(redisSerializer); template.setValueSerializer(jackson2JsonRedisSerializer); template.setHashValueSerializer(jackson2JsonRedisSerializer); template.afterPropertiesSet(); return template; }
Example 7
Source File: RedisCacheConfig.java From ZTuoExchange_framework with MIT License | 6 votes |
/** * RedisTemplate配置 * @param factory * @return */ @Bean public RedisTemplate<String, String> redisTemplate(RedisConnectionFactory factory) { StringRedisTemplate template = new StringRedisTemplate(factory); //定义key序列化方式 //RedisSerializer<String> redisSerializer = new StringRedisSerializer();//Long类型会出现异常信息;需要我们上面的自定义key生成策略,一般没必要 //定义value的序列化方式 Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class); ObjectMapper om = new ObjectMapper(); om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); jackson2JsonRedisSerializer.setObjectMapper(om); // template.setKeySerializer(redisSerializer); template.setValueSerializer(jackson2JsonRedisSerializer); template.setHashValueSerializer(jackson2JsonRedisSerializer); template.afterPropertiesSet(); return template; }
Example 8
Source File: RedisCacheConfig.java From ZTuoExchange_framework with MIT License | 6 votes |
/** * RedisTemplate配置 * @param factory * @return */ @Bean public RedisTemplate<String, String> redisTemplate(RedisConnectionFactory factory) { StringRedisTemplate template = new StringRedisTemplate(factory); //定义key序列化方式 //RedisSerializer<String> redisSerializer = new StringRedisSerializer();//Long类型会出现异常信息;需要我们上面的自定义key生成策略,一般没必要 //定义value的序列化方式 Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class); ObjectMapper om = new ObjectMapper(); om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); jackson2JsonRedisSerializer.setObjectMapper(om); // template.setKeySerializer(redisSerializer); template.setValueSerializer(jackson2JsonRedisSerializer); template.setHashValueSerializer(jackson2JsonRedisSerializer); template.afterPropertiesSet(); return template; }
Example 9
Source File: CacheConfig.java From UserCenter with MIT License | 5 votes |
@Bean public StringRedisTemplate stringRedisTemplate(LettuceConnectionFactory redisConnectionFactory) { StringRedisTemplate template = new StringRedisTemplate(); template.setKeySerializer(new PrefixRedisSerializer()); template.setValueSerializer(new StringRedisSerializer()); template.setConnectionFactory(redisConnectionFactory); template.setHashKeySerializer(new StringRedisSerializer()); template.setHashValueSerializer(new StringRedisSerializer()); template.afterPropertiesSet(); return template; }
Example 10
Source File: CacheConfig.java From microservice-recruit with Apache License 2.0 | 5 votes |
@Bean public StringRedisTemplate stringRedisTemplate(LettuceConnectionFactory redisConnectionFactory) { StringRedisTemplate template = new StringRedisTemplate(); template.setKeySerializer(new PrefixRedisSerializer()); template.setValueSerializer(new StringRedisSerializer()); template.setConnectionFactory(redisConnectionFactory); template.setHashKeySerializer(new StringRedisSerializer()); template.setHashValueSerializer(new StringRedisSerializer()); template.afterPropertiesSet(); return template; }
Example 11
Source File: CacheConfig.java From microservice-recruit with Apache License 2.0 | 5 votes |
@Bean public StringRedisTemplate stringRedisTemplate(LettuceConnectionFactory redisConnectionFactory) { StringRedisTemplate template = new StringRedisTemplate(); template.setKeySerializer(new PrefixRedisSerializer()); template.setValueSerializer(new StringRedisSerializer()); template.setConnectionFactory(redisConnectionFactory); template.setHashKeySerializer(new StringRedisSerializer()); template.setHashValueSerializer(new StringRedisSerializer()); template.afterPropertiesSet(); return template; }
Example 12
Source File: CacheConfig.java From microservice-recruit with Apache License 2.0 | 5 votes |
@Bean public StringRedisTemplate stringRedisTemplate(LettuceConnectionFactory redisConnectionFactory) { StringRedisTemplate template = new StringRedisTemplate(); template.setKeySerializer(new PrefixRedisSerializer()); template.setValueSerializer(new StringRedisSerializer()); template.setConnectionFactory(redisConnectionFactory); template.setHashKeySerializer(new StringRedisSerializer()); template.setHashValueSerializer(new StringRedisSerializer()); template.afterPropertiesSet(); return template; }
Example 13
Source File: CacheConfig.java From microservice-recruit with Apache License 2.0 | 5 votes |
@Bean public StringRedisTemplate stringRedisTemplate(LettuceConnectionFactory redisConnectionFactory) { StringRedisTemplate template = new StringRedisTemplate(); template.setKeySerializer(new PrefixRedisSerializer()); template.setValueSerializer(new StringRedisSerializer()); template.setConnectionFactory(redisConnectionFactory); template.setHashKeySerializer(new StringRedisSerializer()); template.setHashValueSerializer(new StringRedisSerializer()); template.afterPropertiesSet(); return template; }
Example 14
Source File: CacheConfig.java From microservice-recruit with Apache License 2.0 | 5 votes |
@Bean public StringRedisTemplate stringRedisTemplate(LettuceConnectionFactory redisConnectionFactory) { StringRedisTemplate template = new StringRedisTemplate(); template.setKeySerializer(new PrefixRedisSerializer()); template.setValueSerializer(new StringRedisSerializer()); template.setConnectionFactory(redisConnectionFactory); template.setHashKeySerializer(new StringRedisSerializer()); template.setHashValueSerializer(new StringRedisSerializer()); template.afterPropertiesSet(); return template; }
Example 15
Source File: BaseConfiguration.java From common-project with Apache License 2.0 | 5 votes |
/** * Redis模板 * * @param connectionFactory 连接工厂 * @return */ @Bean public StringRedisTemplate redisTemplate(RedisConnectionFactory connectionFactory) { StringRedisTemplate stringRedisTemplate = new StringRedisTemplate(connectionFactory); GenericFastJsonRedisSerializer genericFastJsonRedisSerializer = new GenericFastJsonRedisSerializer(); stringRedisTemplate.setValueSerializer(genericFastJsonRedisSerializer); stringRedisTemplate.setHashValueSerializer(genericFastJsonRedisSerializer); return stringRedisTemplate; }
Example 16
Source File: CacheConfig.java From microservice-recruit with Apache License 2.0 | 5 votes |
@Bean public StringRedisTemplate stringRedisTemplate(LettuceConnectionFactory redisConnectionFactory) { StringRedisTemplate template = new StringRedisTemplate(); template.setKeySerializer(new PrefixRedisSerializer()); template.setValueSerializer(new StringRedisSerializer()); template.setConnectionFactory(redisConnectionFactory); template.setHashKeySerializer(new StringRedisSerializer()); template.setHashValueSerializer(new StringRedisSerializer()); template.afterPropertiesSet(); return template; }
Example 17
Source File: CacheConfig.java From microservice-recruit with Apache License 2.0 | 5 votes |
@Bean public StringRedisTemplate stringRedisTemplate(LettuceConnectionFactory redisConnectionFactory) { StringRedisTemplate template = new StringRedisTemplate(); template.setKeySerializer(new PrefixRedisSerializer()); template.setValueSerializer(new StringRedisSerializer()); template.setConnectionFactory(redisConnectionFactory); template.setHashKeySerializer(new StringRedisSerializer()); template.setHashValueSerializer(new StringRedisSerializer()); template.afterPropertiesSet(); return template; }
Example 18
Source File: CacheConfig.java From microservice-recruit with Apache License 2.0 | 5 votes |
@Bean public StringRedisTemplate stringRedisTemplate(LettuceConnectionFactory redisConnectionFactory) { StringRedisTemplate template = new StringRedisTemplate(); template.setKeySerializer(new PrefixRedisSerializer()); template.setValueSerializer(new StringRedisSerializer()); template.setConnectionFactory(redisConnectionFactory); template.setHashKeySerializer(new StringRedisSerializer()); template.setHashValueSerializer(new StringRedisSerializer()); template.afterPropertiesSet(); return template; }
Example 19
Source File: RedisConfig.java From spring-boot-redis-guava-caffeine-cache with Apache License 2.0 | 5 votes |
@Bean(name = "redisTemplateA") public StringRedisTemplate redisTemplateA(LettuceConnectionFactory factoryA) { StringRedisTemplate template = new StringRedisTemplate(factoryA); RedisSerializer<String> redisSerializer = new StringRedisSerializer(); Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class); ObjectMapper om = new ObjectMapper(); om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); jackson2JsonRedisSerializer.setObjectMapper(om); template.setKeySerializer(redisSerializer); template.setValueSerializer(jackson2JsonRedisSerializer); template.setHashValueSerializer(jackson2JsonRedisSerializer); return template; }
Example 20
Source File: CacheConfig.java From microservice-recruit with Apache License 2.0 | 5 votes |
@Bean public StringRedisTemplate stringRedisTemplate(LettuceConnectionFactory redisConnectionFactory) { StringRedisTemplate template = new StringRedisTemplate(); template.setKeySerializer(new PrefixRedisSerializer()); template.setValueSerializer(new StringRedisSerializer()); template.setConnectionFactory(redisConnectionFactory); template.setHashKeySerializer(new StringRedisSerializer()); template.setHashValueSerializer(new StringRedisSerializer()); template.afterPropertiesSet(); return template; }