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

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

Introduction

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

Prototype

@Override
    public Long delete(Collection<K> keys) 

Source Link

Usage

From source file:com.miko.demo.mongo.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 w  ww .  j  a  v  a2s  . c  o m*/

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

    String key1 = "miko-spring-mongo:counter-test";
    String key2 = "miko-spring-mongo: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: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  av  a  2  s.co  m*/

    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:org.springframework.integration.redis.util.RedisLockRegistryTests.java

@Before
@After//from ww  w. j  a  v a2  s .  c  o m
public void setupShutDown() {
    RedisTemplate<String, ?> template = this.createTemplate();
    template.delete(this.registryKey + ":*");
    template.delete(this.registryKey2 + ":*");
}