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() 

Source Link

Document

Constructs a new StringRedisTemplate instance.

Usage

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

public static void main(String[] args) throws Exception {

    ApplicationContext context = SpringApplication.run(RedisSentinelApplicationConfig.class, args);

    RedisConnectionFactory factory = context.getBean(RedisConnectionFactory.class);

    StringRedisTemplate template = new StringRedisTemplate();
    template.setConnectionFactory(factory);
    template.afterPropertiesSet();/*  w w  w  .  j  a  v a2s. c o m*/

    template.opsForValue().set("loop-forever", "0");

    StopWatch stopWatch = new StopWatch();

    while (true) {

        try {
            String value = "IT:= " + template.opsForValue().increment("loop-forever", 1);
            printBackFromErrorStateInfoIfStopWatchIsRunning(stopWatch);
            System.out.println(value);
        } catch (RuntimeException e) {
            System.err.println(e.getCause().getMessage());
            startStopWatchIfNotRunning(stopWatch);
        }

        Thread.sleep(1000);
    }
}

From source file:io.gravitee.repository.redis.ratelimit.RateLimitRepositoryConfiguration.java

@Bean(name = "rateLimitRedisTemplate")
public StringRedisTemplate redisTemplate(
        org.springframework.data.redis.connection.RedisConnectionFactory redisConnectionFactory) {
    StringRedisTemplate redisTemplate = new StringRedisTemplate();
    redisTemplate.setConnectionFactory(redisConnectionFactory);
    return redisTemplate;
}

From source file:internal.diff.common.configuration.RedisConfiguration.java

@Bean
public StringRedisTemplate stringRedisTemplate() {

    StringRedisTemplate redisTemplate = new StringRedisTemplate();

    redisTemplate.setConnectionFactory(redisConnectionFactory());

    return redisTemplate;
}

From source file:com.jc.hitian.core.redis.RedisAutoConfiguration.java

@Bean
public StringRedisTemplate stringRedisTemplate(JedisConnectionFactory jedisConnectionFactory) {

    StringRedisTemplate redisTemplate = new StringRedisTemplate();
    redisTemplate.setConnectionFactory(jedisConnectionFactory);
    return redisTemplate;
}