@Test public void testEvictionConfigIsNotDerivedFromMapConfig() { MapConfig mapConfig = mock(MapConfig.class); Config config = mock(Config.class); when(config.findMapConfig(eq(CACHE_NAME))).thenReturn(mapConfig); LocalRegionCache.EvictionConfig evictionConfig = mock(LocalRegionCache.EvictionConfig.class); when(evictionConfig.getTimeToLive()).thenReturn(Duration.ofSeconds(1)); new LocalRegionCache(regionFactory, CACHE_NAME, null, null, false, evictionConfig) .cleanup(); verify(evictionConfig).getMaxSize(); verify(evictionConfig).getTimeToLive(); verifyZeroInteractions(mapConfig); }
@SuppressWarnings("Duplicates") void cleanup() { final int maxSize = evictionConfig.getMaxSize(); final long timeToLive = evictionConfig.getTimeToLive().toMillis(); final boolean limitSize = maxSize > 0 && maxSize != Integer.MAX_VALUE; if (limitSize || timeToLive > 0) { final List<EvictionEntry> entries = searchEvictableEntries(timeToLive, limitSize); final int diff = cache.size() - maxSize; final int evictionRate = calculateEvictionRate(diff, maxSize); if (evictionRate > 0 && entries != null) { evictEntries(entries, evictionRate); } } }
LocalRegionCache implements RegionCache { @SuppressWarnings("Duplicates") void cleanup() { final int maxSize = evictionConfig.getMaxSize(); final long timeToLive = evictionConfig.getTimeToLive().toMillis(); final boolean limitSize = maxSize > 0 && maxSize != Integer.MAX_VALUE; if (limitSize || timeToLive > 0) { final List<EvictionEntry> entries = searchEvictableEntries(timeToLive, limitSize); final int diff = cache.size() - maxSize; final int evictionRate = calculateEvictionRate(diff, maxSize); if (evictionRate > 0 && entries != null) { evictEntries(entries, evictionRate); } } } }
LocalRegionCache implements RegionCache { @SuppressWarnings("Duplicates") void cleanup() { final int maxSize = evictionConfig.getMaxSize(); final long timeToLive = evictionConfig.getTimeToLive().toMillis(); final boolean limitSize = maxSize > 0 && maxSize != Integer.MAX_VALUE; if (limitSize || timeToLive > 0) { final List<EvictionEntry> entries = searchEvictableEntries(timeToLive, limitSize); final int diff = cache.size() - maxSize; final int evictionRate = calculateEvictionRate(diff, maxSize); if (evictionRate > 0 && entries != null) { evictEntries(entries, evictionRate); } } } LocalRegionCache(final RegionFactory regionFactory, final String name,
                            final HazelcastInstance hazelcastInstance, final DomainDataRegionConfig regionConfig);  LocalRegionCache(final RegionFactory regionFactory, final String name,
                            final HazelcastInstance hazelcastInstance, final DomainDataRegionConfig regionConfig,
                            final boolean withTopic);  LocalRegionCache(final RegionFactory regionFactory, final String name,
                            final HazelcastInstance hazelcastInstance, final DomainDataRegionConfig regionConfig,
                            final boolean withTopic, final EvictionConfig evictionConfig); }
LocalRegionCache implements RegionCache { @SuppressWarnings("Duplicates") void cleanup() { final int maxSize = evictionConfig.getMaxSize(); final long timeToLive = evictionConfig.getTimeToLive().toMillis(); final boolean limitSize = maxSize > 0 && maxSize != Integer.MAX_VALUE; if (limitSize || timeToLive > 0) { final List<EvictionEntry> entries = searchEvictableEntries(timeToLive, limitSize); final int diff = cache.size() - maxSize; final int evictionRate = calculateEvictionRate(diff, maxSize); if (evictionRate > 0 && entries != null) { evictEntries(entries, evictionRate); } } } LocalRegionCache(final RegionFactory regionFactory, final String name,
                            final HazelcastInstance hazelcastInstance, final DomainDataRegionConfig regionConfig);  LocalRegionCache(final RegionFactory regionFactory, final String name,
                            final HazelcastInstance hazelcastInstance, final DomainDataRegionConfig regionConfig,
                            final boolean withTopic);  LocalRegionCache(final RegionFactory regionFactory, final String name,
                            final HazelcastInstance hazelcastInstance, final DomainDataRegionConfig regionConfig,
                            final boolean withTopic, final EvictionConfig evictionConfig); @Override void afterUpdate(final Object key, final Object newValue, final Object newVersion); @Override boolean contains(final Object key); @Override void evictData(); @Override void evictData(final Object key); @Override Object get(final Object key, final long txTimestamp); @Override long getElementCountInMemory(); @Override String getName(); @Override RegionFactory getRegionFactory(); @Override long getSizeInMemory(); @Override boolean put(final Object key, final Object value, final long txTimestamp, final Object version); @Override void unlockItem(final Object key, final SoftLock lock); long nextTimestamp(); @Override void destroy(); }
LocalRegionCache implements RegionCache { @SuppressWarnings("Duplicates") void cleanup() { final int maxSize = evictionConfig.getMaxSize(); final long timeToLive = evictionConfig.getTimeToLive().toMillis(); final boolean limitSize = maxSize > 0 && maxSize != Integer.MAX_VALUE; if (limitSize || timeToLive > 0) { final List<EvictionEntry> entries = searchEvictableEntries(timeToLive, limitSize); final int diff = cache.size() - maxSize; final int evictionRate = calculateEvictionRate(diff, maxSize); if (evictionRate > 0 && entries != null) { evictEntries(entries, evictionRate); } } } LocalRegionCache(final RegionFactory regionFactory, final String name,
                            final HazelcastInstance hazelcastInstance, final DomainDataRegionConfig regionConfig);  LocalRegionCache(final RegionFactory regionFactory, final String name,
                            final HazelcastInstance hazelcastInstance, final DomainDataRegionConfig regionConfig,
                            final boolean withTopic);  LocalRegionCache(final RegionFactory regionFactory, final String name,
                            final HazelcastInstance hazelcastInstance, final DomainDataRegionConfig regionConfig,
                            final boolean withTopic, final EvictionConfig evictionConfig); @Override void afterUpdate(final Object key, final Object newValue, final Object newVersion); @Override boolean contains(final Object key); @Override void evictData(); @Override void evictData(final Object key); @Override Object get(final Object key, final long txTimestamp); @Override long getElementCountInMemory(); @Override String getName(); @Override RegionFactory getRegionFactory(); @Override long getSizeInMemory(); @Override boolean put(final Object key, final Object value, final long txTimestamp, final Object version); @Override void unlockItem(final Object key, final SoftLock lock); long nextTimestamp(); @Override void destroy();  }