Updates to redis repositories

* Ensure prefix ends with period
* Allow prefix and key index to be set separately
This commit is contained in:
Dave Syer
2014-01-22 11:41:09 +00:00
parent d64b18cca9
commit 195eb9f9bc
5 changed files with 121 additions and 35 deletions

View File

@@ -37,20 +37,23 @@ public class RedisMetricRepositoryTests {
@Rule
public RedisServer redis = RedisServer.running();
private RedisMetricRepository repository;
private String prefix;
@Before
public void init() {
this.repository = new RedisMetricRepository(this.redis.getResource());
this.prefix = "spring.test." + System.currentTimeMillis();
this.repository.setPrefix(this.prefix);
}
@After
public void clear() {
assertNotNull(new StringRedisTemplate(this.redis.getResource()).opsForValue()
.get("spring.metrics.foo"));
.get(this.prefix + ".foo"));
this.repository.reset("foo");
this.repository.reset("bar");
assertNull(new StringRedisTemplate(this.redis.getResource()).opsForValue().get(
"spring.metrics.foo"));
this.prefix + ".foo"));
}
@Test