Java Code Examples for org.springframework.data.redis.serializer.RedisSerializationContext#SerializationPair
The following examples show how to use
org.springframework.data.redis.serializer.RedisSerializationContext#SerializationPair .
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: RedisConfig.java From biliob_backend with MIT License | 6 votes |
@Bean public RedisCacheConfiguration redisCacheConfiguration() { Jackson2JsonRedisSerializer<Object> 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); RedisSerializationContext.SerializationPair<Object> pair = RedisSerializationContext.SerializationPair.fromSerializer(jackson2JsonRedisSerializer); return RedisCacheConfiguration.defaultCacheConfig() .entryTtl(Duration.ofHours(1)) .serializeValuesWith(pair) .serializeKeysWith( RedisSerializationContext.SerializationPair.fromSerializer( new StringRedisSerializer())); }
Example 2
Source File: RedisConfig.java From kvf-admin with MIT License | 5 votes |
@Primary @Bean public CacheManager cacheManager(RedisConnectionFactory factory) { //对象的序列化 RedisSerializationContext.SerializationPair valueSerializationPair = RedisSerializationContext.SerializationPair.fromSerializer(jackson2JsonRedisSerializer()); //全局redis缓存过期时间 RedisCacheConfiguration redisCacheConfiguration = RedisCacheConfiguration.defaultCacheConfig() .entryTtl(Duration.ofDays(1)) // .serializeKeysWith() .serializeValuesWith(valueSerializationPair); return new RedisCacheManager(RedisCacheWriter.nonLockingRedisCacheWriter(factory), redisCacheConfiguration); }
Example 3
Source File: RedisConfig.java From SpringCloud with Apache License 2.0 | 5 votes |
@Bean public CacheManager cacheManager(RedisConnectionFactory factory) { //对象的序列化 RedisSerializationContext.SerializationPair valueSerializationPair = RedisSerializationContext.SerializationPair.fromSerializer(jackson2JsonRedisSerializer()); //全局redis缓存过期时间 RedisCacheConfiguration redisCacheConfiguration = RedisCacheConfiguration.defaultCacheConfig() .entryTtl(Duration.ofDays(1)) // .serializeKeysWith() .serializeValuesWith(valueSerializationPair); return new RedisCacheManager(RedisCacheWriter.nonLockingRedisCacheWriter(factory), redisCacheConfiguration); }