@Test public void testEvictionConfigIsDerivedFromMapConfig() { MapConfig mapConfig = mock(MapConfig.class); Config config = mock(Config.class); when(config.findMapConfig(eq(CACHE_NAME))).thenReturn(mapConfig); com.hazelcast.config.EvictionConfig maxSizeConfig = mock(com.hazelcast.config.EvictionConfig.class); when(mapConfig.getEvictionConfig()).thenReturn(maxSizeConfig); HazelcastInstance instance = mock(HazelcastInstance.class); when(instance.getConfig()).thenReturn(config); new LocalRegionCache(CACHE_NAME, instance, null, false) .cleanup(); verify(maxSizeConfig).getSize(); verify(mapConfig).getTimeToLiveSeconds(); }
void cleanup() { final int maxSize = evictionConfig.getMaxSize(); final long timeToLive = evictionConfig.getTimeToLive().toMillis(); boolean limitSize = maxSize > 0 && maxSize != Integer.MAX_VALUE; if (limitSize || timeToLive > 0) { 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 { void cleanup() { final int maxSize = evictionConfig.getMaxSize(); final long timeToLive = evictionConfig.getTimeToLive().toMillis(); boolean limitSize = maxSize > 0 && maxSize != Integer.MAX_VALUE; if (limitSize || timeToLive > 0) { 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 { void cleanup() { final int maxSize = evictionConfig.getMaxSize(); final long timeToLive = evictionConfig.getTimeToLive().toMillis(); boolean limitSize = maxSize > 0 && maxSize != Integer.MAX_VALUE; if (limitSize || timeToLive > 0) { 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 String name, final HazelcastInstance hazelcastInstance,
                            final CacheDataDescription metadata);  LocalRegionCache(final String name, final HazelcastInstance hazelcastInstance,
                            final CacheDataDescription metadata, final boolean withTopic);  LocalRegionCache(final String name, final HazelcastInstance hazelcastInstance,
                            final CacheDataDescription metadata, final boolean withTopic,
                            final EvictionConfig evictionConfig); }
LocalRegionCache implements RegionCache { void cleanup() { final int maxSize = evictionConfig.getMaxSize(); final long timeToLive = evictionConfig.getTimeToLive().toMillis(); boolean limitSize = maxSize > 0 && maxSize != Integer.MAX_VALUE; if (limitSize || timeToLive > 0) { 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 String name, final HazelcastInstance hazelcastInstance,
                            final CacheDataDescription metadata);  LocalRegionCache(final String name, final HazelcastInstance hazelcastInstance,
                            final CacheDataDescription metadata, final boolean withTopic);  LocalRegionCache(final String name, final HazelcastInstance hazelcastInstance,
                            final CacheDataDescription metadata, final boolean withTopic,
                            final EvictionConfig evictionConfig); @Override Object get(final Object key, long txTimestamp); @Override boolean insert(final Object key, final Object value, final Object currentVersion); @Override boolean put(final Object key, final Object value, final long txTimestamp, final Object version); @Override boolean update(final Object key, final Object newValue, final Object newVersion, final SoftLock softLock); @Override boolean remove(final Object key); @Override SoftLock tryLock(final Object key, final Object version); @Override void unlock(final Object key, final SoftLock lock); @Override boolean contains(final Object key); @Override void clear(); @Override void destroy(); @Override long size(); @Override long getSizeInMemory(); @Override Map asMap(); }
LocalRegionCache implements RegionCache { void cleanup() { final int maxSize = evictionConfig.getMaxSize(); final long timeToLive = evictionConfig.getTimeToLive().toMillis(); boolean limitSize = maxSize > 0 && maxSize != Integer.MAX_VALUE; if (limitSize || timeToLive > 0) { 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 String name, final HazelcastInstance hazelcastInstance,
                            final CacheDataDescription metadata);  LocalRegionCache(final String name, final HazelcastInstance hazelcastInstance,
                            final CacheDataDescription metadata, final boolean withTopic);  LocalRegionCache(final String name, final HazelcastInstance hazelcastInstance,
                            final CacheDataDescription metadata, final boolean withTopic,
                            final EvictionConfig evictionConfig); @Override Object get(final Object key, long txTimestamp); @Override boolean insert(final Object key, final Object value, final Object currentVersion); @Override boolean put(final Object key, final Object value, final long txTimestamp, final Object version); @Override boolean update(final Object key, final Object newValue, final Object newVersion, final SoftLock softLock); @Override boolean remove(final Object key); @Override SoftLock tryLock(final Object key, final Object version); @Override void unlock(final Object key, final SoftLock lock); @Override boolean contains(final Object key); @Override void clear(); @Override void destroy(); @Override long size(); @Override long getSizeInMemory(); @Override Map asMap();  }