2
0
mirror of https://github.com/proxiodev/RedisBungee.git synced 2024-12-23 10:38:01 +00:00

Make sure we don't spuriously empty caches.

This commit is contained in:
Tux 2015-12-14 17:37:13 -05:00
parent 7ee37ae4cb
commit 020341590f
2 changed files with 14 additions and 2 deletions

View File

@ -64,7 +64,7 @@ public class InternalCache<K, V> {
long fixedReference = System.currentTimeMillis();
for (Iterator<Map.Entry<K, Holder>> it = map.entrySet().iterator(); it.hasNext(); ) {
Map.Entry<K, Holder> entry = it.next();
if (entry.getValue().expiry > fixedReference)
if (entry.getValue().expiry <= fixedReference)
it.remove();
}
}

View File

@ -97,7 +97,19 @@ public class InternalCacheTest {
}
}));
try {
Thread.sleep(20);
Thread.sleep(5);
} catch (InterruptedException e) {
throw new AssertionError(e);
}
cache.cleanup();
Assert.assertEquals(one, cache.get("hi", new Callable<Object>() {
@Override
public Object call() throws Exception {
return two;
}
}));
try {
Thread.sleep(5);
} catch (InterruptedException e) {
throw new AssertionError(e);
}