LRURegion implements CacheRegion<Long, T> { @Override public Collection<T> values() { lock.lock(); try { return Collections2.transform(cachedBlocks.values(), new Function<EntryWrapper, T>() { @Override public T apply(EntryWrapper entryWrapper) { return entryWrapper.getEntry(); } }); } finally { lock.unlock(); } } LRURegion(String name); @Override long lastRegionAccess(); @Override String name(); @Override long memorySize(); @Override long reduceBy(long reduceSize); @Override T putEntry(Long key, T entry); @Override boolean contains(Long key); @Override T getEntry(Long key); @Override boolean removeEntry(Long key); @Override Collection<T> values(); @Override int size(); @Override void clear(); @Override String toString();  }
@Test public void testValues() { int testSize = 100000; long blockSize = 9999; LRURegion<MockCacheEntry<Long>> region = new LRURegion<>("region"); for(int i=0; i<testSize; i++) { region.putEntry((long)i, new MockCacheEntry<>(blockSize, (long)i)); } Collection<MockCacheEntry<Long>> entries = region.values(); assertThat(entries.size(), is(testSize)); int counter = 0; for(MockCacheEntry<Long> entry : entries) { assertThat(entry.getValue(), is((long)counter)); counter++; } }