Example usage for org.springframework.data.redis.core StringRedisTemplate StringRedisTemplate

List of usage examples for org.springframework.data.redis.core StringRedisTemplate StringRedisTemplate

Introduction

In this page you can find the example usage for org.springframework.data.redis.core StringRedisTemplate StringRedisTemplate.

Prototype

public StringRedisTemplate(RedisConnectionFactory connectionFactory) 

Source Link

Document

Constructs a new StringRedisTemplate instance ready to be used.

Usage

From source file:locksdemo.RedisUtils.java

static RedisOperations<String, String> stringTemplate(RedisConnectionFactory redisConnectionFactory) {
    return new StringRedisTemplate(redisConnectionFactory);
}

From source file:com.greglturnquist.springagram.backend.RedisConfig.java

@Bean
public StringRedisTemplate template(RedisConnectionFactory factory) {
    return new StringRedisTemplate(factory);
}

From source file:com.jim.im.login.config.RedisConfig.java

/**
* @Title: redisTemplate  //from  w  w w . j  a  v  a 2 s .  c o  m
* @Description: ?RedisTemplate
* @param factory
* @return StringRedisTemplate
* @throws
 */
@Bean
public StringRedisTemplate redisTemplate(RedisConnectionFactory factory) {
    final StringRedisTemplate template = new StringRedisTemplate(factory);
    return template;
}

From source file:edu.kit.scc.ServiceConfiguration.java

@Bean
StringRedisTemplate template(JedisConnectionFactory jedisConnectionFactory) {
    return new StringRedisTemplate(jedisConnectionFactory);
}

From source file:org.apereo.openlrs.storage.redis.RedisPubSubConfig.java

@Bean
public StringRedisTemplate template(RedisConnectionFactory connectionFactory) {
    return new StringRedisTemplate(connectionFactory);
}

From source file:org.apereo.openlrs.RedisElasticsearchConfig.java

@Conditional(RedisEnabledCondition.class)
@Bean/*www.  j  a  v  a 2 s.co  m*/
public StringRedisTemplate template(RedisConnectionFactory connectionFactory) {
    return new StringRedisTemplate(connectionFactory);
}

From source file:com.springsource.greenhouse.config.KeyValueConfig.java

@Bean
public StringRedisTemplate redisTemplate() {
    return new StringRedisTemplate(redisConnectionFactory());
}

From source file:example.springdata.redis.sentinel.RedisSentinelApplication.java

public @Bean StringRedisTemplate redisTemplate() {
    return new StringRedisTemplate(connectionFactory());
}

From source file:org.springframework.integration.redis.inbound.RedisInboundChannelAdapterTests.java

private void testRedisInboundChannelAdapterGuts(int iteration) throws Exception {
    int numToTest = 10;
    String redisChannelName = "testRedisInboundChannelAdapterChannel";
    QueueChannel channel = new QueueChannel();

    JedisConnectionFactory connectionFactory = new JedisConnectionFactory();
    connectionFactory.setPort(7379);/*  w w  w . j  a  va 2s . c  o  m*/
    connectionFactory.afterPropertiesSet();

    RedisInboundChannelAdapter adapter = new RedisInboundChannelAdapter(connectionFactory);
    adapter.setTopics("testRedisInboundChannelAdapterChannel");
    adapter.setOutputChannel(channel);
    adapter.afterPropertiesSet();
    adapter.start();

    RedisMessageListenerContainer container = waitUntilSubscribed(adapter);

    StringRedisTemplate redisTemplate = new StringRedisTemplate(connectionFactory);
    redisTemplate.afterPropertiesSet();
    for (int i = 0; i < numToTest; i++) {
        String message = "test-" + i + " iteration " + iteration;
        redisTemplate.convertAndSend(redisChannelName, message);
        logger.debug("Sent " + message);
    }
    int counter = 0;
    for (int i = 0; i < numToTest; i++) {
        Message<?> message = channel.receive(5000);
        if (message == null) {
            throw new RuntimeException("Failed to receive message # " + i + " iteration " + iteration);
        }
        assertNotNull(message);
        assertTrue(message.getPayload().toString().startsWith("test-"));
        counter++;
    }
    assertEquals(numToTest, counter);
    adapter.stop();
    container.stop();
    connectionFactory.destroy();
}