Search in sources :

Example 11 with RedisTemplate

use of org.springframework.data.redis.core.RedisTemplate in project camel by apache.

the class RedisProducerIntegrationTest method createRegistry.

@Override
protected JndiRegistry createRegistry() throws Exception {
    JndiRegistry registry = super.createRegistry();
    redisTemplate = new RedisTemplate();
    redisTemplate.setConnectionFactory(CONNECTION_FACTORY);
    redisTemplate.afterPropertiesSet();
    registry.bind("redisTemplate", redisTemplate);
    return registry;
}
Also used : JndiRegistry(org.apache.camel.impl.JndiRegistry) RedisTemplate(org.springframework.data.redis.core.RedisTemplate)

Example 12 with RedisTemplate

use of org.springframework.data.redis.core.RedisTemplate in project paascloud-master by paascloud.

the class RedisConfiguration method redisTemplate.

@Bean("redisTemplate")
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
    RedisTemplate<String, Object> template = new RedisTemplate<>();
    template.setConnectionFactory(factory);
    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);
    template.setValueSerializer(jackson2JsonRedisSerializer);
    template.setKeySerializer(stringRedisSerializer());
    template.afterPropertiesSet();
    return template;
}
Also used : RedisTemplate(org.springframework.data.redis.core.RedisTemplate) Jackson2JsonRedisSerializer(org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Bean(org.springframework.context.annotation.Bean)

Aggregations

RedisTemplate (org.springframework.data.redis.core.RedisTemplate)12 JndiRegistry (org.apache.camel.impl.JndiRegistry)3 ValueOperations (org.springframework.data.redis.core.ValueOperations)3 ArrayList (java.util.ArrayList)2 DefaultRedisList (org.springframework.data.redis.support.collections.DefaultRedisList)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 BlockingQueue (java.util.concurrent.BlockingQueue)1 TimeUnit (java.util.concurrent.TimeUnit)1 ReadWriteLock (java.util.concurrent.locks.ReadWriteLock)1 ReentrantReadWriteLock (java.util.concurrent.locks.ReentrantReadWriteLock)1 Cache (org.apache.ibatis.cache.Cache)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 Bean (org.springframework.context.annotation.Bean)1 BoundListOperations (org.springframework.data.redis.core.BoundListOperations)1 RedisCallback (org.springframework.data.redis.core.RedisCallback)1 StringRedisTemplate (org.springframework.data.redis.core.StringRedisTemplate)1 Jackson2JsonRedisSerializer (org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer)1 StringRedisSerializer (org.springframework.data.redis.serializer.StringRedisSerializer)1