use long instead of Instant for time

Working with longs is faster and requires less
cache. The space in L123 caches is precious.
This commit is contained in:
2019-08-19 18:58:24 +02:00
parent feda901f6d
commit 00c20dae6b
2 changed files with 70 additions and 73 deletions

View File

@@ -30,16 +30,16 @@ public class HotEntryCacheTest {
@Test(invocationCount = 1)
public void testRemovalListenerCalledOnExpire() throws InterruptedException {
final Duration originalMinSleepPeriod = HotEntryCache.getMinSleepPeriod();
final Duration originalMaxSleepPeriod = HotEntryCache.getMaxSleepPeriod();
final long originalMinSleepPeriod = HotEntryCache.getMinSleepPeriod();
final long originalMaxSleepPeriod = HotEntryCache.getMaxSleepPeriod();
try {
final String key = "key";
final String value = "value";
final CountDownLatch latch = new CountDownLatch(1);
final HotEntryCache<String, String> cache = new HotEntryCache<>(Duration.ofMillis(1), "cache-" + ++cacheId);
HotEntryCache.setMinSleepPeriod(Duration.ofMillis(1));
HotEntryCache.setMaxSleepPeriod(Duration.ofMillis(10));
HotEntryCache.setMinSleepPeriod(1);
HotEntryCache.setMaxSleepPeriod(10);
cache.addListener((k, v) -> {
Assert.assertEquals(k, key);
Assert.assertEquals(v, value);