LocalRegionCache implements RegionCache { void cleanup() { final int maxSize; final long timeToLive; if (config != null) { maxSize = config.getMaxSizeConfig().getSize(); timeToLive = config.getTimeToLiveSeconds() * SEC_TO_MS; } else { maxSize = MAX_SIZE; timeToLive = CacheEnvironment.getDefaultCacheTimeoutInMillis(); } 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); Object get(final Object key, long txTimestamp); @Override boolean insert(final Object key, final Object value, final Object currentVersion); boolean put(final Object key, final Object value, final long txTimestamp, final Object version); boolean update(final Object key, final Object newValue, final Object newVersion, final SoftLock softLock); boolean remove(final Object key); SoftLock tryLock(final Object key, final Object version); void unlock(final Object key, SoftLock lock); boolean contains(final Object key); void clear(); long size(); long getSizeInMemory(); Map asMap();  }
@Test public void cleanup() { LocalRegionCache cache = new LocalRegionCache(CACHE_NAME, null, null); int version = 1; long alreadyExpired = System.currentTimeMillis() - CacheEnvironment.getDefaultCacheTimeoutInMillis() - 1; cache.cache.put(1, new Value(version, alreadyExpired, 1)); cache.cache.put(2, new ExpiryMarker(version, alreadyExpired, "2")); cache.cleanup(); assertEquals(0, cache.size()); }