public class RandomEvictionAlgorithm implements EvictionAlgorithm {
private static Random random = new Random();
@SuppressWarnings("unchecked")
public void evict(CacheImpl cache) {
CacheEntry lruCacheEntry = null;
Collection all = cache.getAll();
int evictionIndex = random.nextInt(all.size());
int index = 0;
for (Object anAll : all) {
CacheEntry cacheEntry = (CacheEntry) anAll;
if (index == evictionIndex) {
lruCacheEntry = cacheEntry;
break;
}
index++;