List of usage examples for org.springframework.data.redis.core RedisTemplate keys
@Override @SuppressWarnings("unchecked") public Set<K> keys(K pattern)
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 w w. j a v a2 s . c om 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 w ww . j a v a2s .c o 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
private void waitForExpire(String key) throws Exception { RedisTemplate<String, ?> template = this.createTemplate(); int n = 0;// ww w .ja v a2 s. c om while (n++ < 100 && template.keys(this.registryKey + ":" + key).size() > 0) { Thread.sleep(100); } assertTrue(key + " key did not expire", n < 100); }