*/
public class LeastRecentlyUsedEvictionAlgorithm implements EvictionAlgorithm {
@SuppressWarnings("unchecked")
public void evict(CacheImpl cache) {
CacheEntry lruCacheEntry = null;
for (Object o : cache.getAll()) {
CacheEntry cacheEntry = (CacheEntry) o;
if (lruCacheEntry == null) {
lruCacheEntry = cacheEntry;
} else if (lruCacheEntry.getLastAccessed() > cacheEntry.getLastAccessed()) {
lruCacheEntry = cacheEntry;
}
}
if (lruCacheEntry != null) {
cache.evict(lruCacheEntry.getKey());