Closed carloshenrique153 closed 4 years ago
Well~, I found something wrong with your test case ^ ^
assertEquals("foo", cache.get("bar")); <============ this fails
There is no key "bar" in the your cache, only the key "foo";
I guess you may write like this
`
@Test
public void shouldSupportVariableExpiration() throws InterruptedException {
ExpiringMap<String, Object> cache = ExpiringMap.builder()
.variableExpiration()
.build();
cache.put("hello", "world", ExpirationPolicy.CREATED, 1000L, TimeUnit.MILLISECONDS);
cache.put("foo", "bar", ExpirationPolicy.CREATED, 2000L, TimeUnit.MILLISECONDS);
// both keys are available in the first second
assertEquals("world", cache.get("hello"));
assertEquals("bar", cache.get("foo"));
// after waiting 1 second, only "hello" should have expired
Thread.sleep(1001L);
assertNull(cache.get("hello"));
assertEquals("bar", cache.get("foo"));
// after waiting a total of 2 seconds, both keys should have expired
Thread.sleep(1000L);
assertNull(cache.get("hello"));
assertNull(cache.get("bar"));
}
`
Omg haha, sorry, thanks for looking into this!
Hi, thanks for sharing this library, it's very handy.
Can I get help with the test below? I don't understand why it's failing, it's either a bug or I misinterpreted the documentation, because both keys are expiring at the same time, even though they have different TTL: