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

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

Introduction

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

Prototype

public RedisTemplate() 

Source Link

Document

Constructs a new RedisTemplate instance.

Usage

From source file:com.miko.demo.postgresql.service.RedisRemovalTest.java

@Test
public void removalKeyValueTest() {
    RedisTemplate<String, Long> redis = new RedisTemplate<>();
    redis.setConnectionFactory(connectionFactory);
    redis.setKeySerializer(RedisStringSerializer.INSTANCE);
    redis.setValueSerializer(RedisLongSerializer.INSTANCE);
    redis.afterPropertiesSet();//from www.j  a  v a2s  . c  om

    ValueOperations<String, Long> ops = redis.opsForValue();

    String key1 = "miko-spring-postgresql:counter-test";
    String key2 = "miko-spring-postgresql:counter-test-2";

    Set<String> keys = redis.keys(key1);
    for (String foundKey : keys) {
        logger.debug("Found Key= " + foundKey + " value= " + ops.get(foundKey));
    }

    redis.delete(key2);

}

From source file:curly.commons.config.cache.RedisCacheConfig.java

@Bean
RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory connectionFactory) {
    RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>();
    redisTemplate.setConnectionFactory(connectionFactory);
    return redisTemplate;
}

From source file:com.hillert.botanic.config.HttpSessionConfig.java

@Bean
public RedisTemplate<String, ExpiringSession> redisTemplate(RedisConnectionFactory connectionFactory) {
    RedisTemplate<String, ExpiringSession> template = new RedisTemplate<String, ExpiringSession>();
    template.setKeySerializer(new StringRedisSerializer());
    template.setHashKeySerializer(new StringRedisSerializer());
    template.setConnectionFactory(connectionFactory);
    return template;
}

From source file:org.cloudfoundry.community.servicebroker.vrealize.CloudConfig.java

@Bean
@Qualifier("sibTemplate")
RedisTemplate<String, VrServiceInstanceBinding> sibTemplate() {
    RedisTemplate<String, VrServiceInstanceBinding> template = new RedisTemplate<String, VrServiceInstanceBinding>();
    template.setConnectionFactory(jedisConnectionFactory());
    return template;
}

From source file:com.miko.demo.mongo.service.RedisInitTest.java

@Test
public void testRedisTemplate() {
    RedisTemplate<String, Long> redis = new RedisTemplate<>();
    redis.setConnectionFactory(connectionFactory);
    redis.setKeySerializer(RedisStringSerializer.INSTANCE);
    redis.setValueSerializer(RedisLongSerializer.INSTANCE);
    redis.afterPropertiesSet();/*from  www. j a va2  s  . com*/

    ValueOperations<String, Long> ops = redis.opsForValue();

    String key1 = "miko-spring-mongo:counter-test";
    String key2 = "miko-spring-mongo:counter-test-2";
    logger.debug("redistTemplate ops = " + ops);

    ops.setIfAbsent(key1, 1L);
    ops.setIfAbsent(key2, 22L);
    Long l = ops.increment(key1, 1);

    logger.debug("redistTemplate L = " + l);

    assertThat(l, is(greaterThan(0L)));
}

From source file:com.miko.demo.postgresql.service.RedisInitTest.java

@Test
public void testRedisTemplate() {
    RedisTemplate<String, Long> redis = new RedisTemplate<>();
    redis.setConnectionFactory(connectionFactory);
    redis.setKeySerializer(RedisStringSerializer.INSTANCE);
    redis.setValueSerializer(RedisLongSerializer.INSTANCE);
    redis.afterPropertiesSet();/*  w  w  w. jav  a  2  s . c o m*/

    ValueOperations<String, Long> ops = redis.opsForValue();

    String key1 = "miko-spring-postgresql:counter-test";
    String key2 = "miko-spring-postgresql:counter-test-2";
    logger.debug("redistTemplate ops = " + ops);

    ops.setIfAbsent(key1, 1L);
    ops.setIfAbsent(key2, 22L);
    Long l = ops.increment(key1, 1);

    logger.debug("redistTemplate L = " + l);

    assertThat(l, is(greaterThan(0L)));
}

From source file:com.hp.autonomy.frontend.find.hod.beanconfiguration.RedisConfiguration.java

@Bean
public RedisTemplate<Object, Object> cachingRedisTemplate() {
    final RedisTemplate<Object, Object> template = new RedisTemplate<>();
    template.setConnectionFactory(redisConnectionFactory());
    return template;
}

From source file:com.miko.demo.mongo.service.RedisInitTest.java

@Test
public void testKeyValue() {
    RedisTemplate<String, Long> redis = new RedisTemplate<>();
    redis.setConnectionFactory(connectionFactory);
    redis.setKeySerializer(RedisStringSerializer.INSTANCE);
    redis.setValueSerializer(RedisLongSerializer.INSTANCE);
    redis.afterPropertiesSet();/*from  w w  w  .j  av  a  2  s .c  o  m*/

    ValueOperations<String, Long> ops = redis.opsForValue();
    String key = "spring-postgresql:counter-test";

    Long value = ops.get(key);
    logger.debug("VALUE = " + value);

    assertThat(value, notNullValue());
}

From source file:com.miko.demo.postgresql.service.RedisInitTest.java

@Test
public void testKeyValue() {
    RedisTemplate<String, Long> redis = new RedisTemplate<>();
    redis.setConnectionFactory(connectionFactory);
    redis.setKeySerializer(RedisStringSerializer.INSTANCE);
    redis.setValueSerializer(RedisLongSerializer.INSTANCE);
    redis.afterPropertiesSet();//  ww  w  .jav  a 2s  .  c o m

    ValueOperations<String, Long> ops = redis.opsForValue();
    String key = "miko-spring-postgresql:counter-test";

    Long value = ops.get(key);
    logger.debug("VALUE = " + value);

    assertThat(value, notNullValue());
}