Search in sources :

Example 6 with RedisTemplate

use of org.springframework.data.redis.core.RedisTemplate in project roof-im by madfroglx.

the class RedisBlockingQueueRequestMessageDriveEnterPoint method onInit.

@Override
protected void onInit() {
    this.queues = new ArrayList();
    for (RedisTemplate redisTemplate : redisTemplates) {
        RedisList<E> redisList = new DefaultRedisList<E>(redisTemplate.boundListOps(serverNameBuilder.getName()));
        this.queues.add(redisList);
    }
}
Also used : RedisTemplate(org.springframework.data.redis.core.RedisTemplate) DefaultRedisList(org.springframework.data.redis.support.collections.DefaultRedisList) ArrayList(java.util.ArrayList)

Example 7 with RedisTemplate

use of org.springframework.data.redis.core.RedisTemplate in project roof-im by madfroglx.

the class RedisBlockingQueueLoadBalanceMessagePublisher method createQueues.

@Override
protected List<BlockingQueue> createQueues(String serverName) {
    List<BlockingQueue> list = new ArrayList<>();
    for (RedisTemplate redisTemplate : redisTemplates) {
        BoundListOperations boundListOperations = redisTemplate.boundListOps(serverName);
        BlockingQueue blockingQueue = new DefaultRedisList(boundListOperations);
        list.add(blockingQueue);
    }
    return list;
}
Also used : BlockingQueue(java.util.concurrent.BlockingQueue) BoundListOperations(org.springframework.data.redis.core.BoundListOperations) RedisTemplate(org.springframework.data.redis.core.RedisTemplate) DefaultRedisList(org.springframework.data.redis.support.collections.DefaultRedisList) ArrayList(java.util.ArrayList)

Example 8 with RedisTemplate

use of org.springframework.data.redis.core.RedisTemplate in project spring-boot by spring-projects.

the class RedisUtils method createRedisTemplate.

static <K, V> RedisTemplate<K, V> createRedisTemplate(RedisConnectionFactory connectionFactory, Class<V> valueClass) {
    RedisTemplate<K, V> redisTemplate = new RedisTemplate<>();
    redisTemplate.setKeySerializer(new StringRedisSerializer());
    redisTemplate.setValueSerializer(new GenericToStringSerializer<>(valueClass));
    // avoids proxy
    redisTemplate.setExposeConnection(true);
    redisTemplate.setConnectionFactory(connectionFactory);
    redisTemplate.afterPropertiesSet();
    return redisTemplate;
}
Also used : StringRedisSerializer(org.springframework.data.redis.serializer.StringRedisSerializer) StringRedisTemplate(org.springframework.data.redis.core.StringRedisTemplate) RedisTemplate(org.springframework.data.redis.core.RedisTemplate)

Example 9 with RedisTemplate

use of org.springframework.data.redis.core.RedisTemplate in project spring-boot-mybatis-with-redis by Lovelcp.

the class RedisCache method removeObject.

/**
     * Remove cached query result from redis
     *
     * @param key
     * @return
     */
@Override
@SuppressWarnings("unchecked")
public Object removeObject(Object key) {
    RedisTemplate redisTemplate = getRedisTemplate();
    redisTemplate.delete(key);
    logger.debug("Remove cached query result from redis");
    return null;
}
Also used : RedisTemplate(org.springframework.data.redis.core.RedisTemplate)

Example 10 with RedisTemplate

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

the class RedisStringIdempotentRepositoryIntegrationTest 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)

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