@Override public int compare(CachedResource cr1, CachedResource cr2) { long nc1 = cr1.getNextCheck(); long nc2 = cr2.getNextCheck(); // Oldest resource should be first (so iterator goes from oldest to // youngest. if (nc1 == nc2) { return 0; } else if (nc1 > nc2) { return -1; } else { return 1; } } }
@Override public int compare(CachedResource cr1, CachedResource cr2) { long nc1 = cr1.getNextCheck(); long nc2 = cr2.getNextCheck(); // Oldest resource should be first (so iterator goes from oldest to // youngest. if (nc1 == nc2) { return 0; } else if (nc1 > nc2) { return -1; } else { return 1; } } }
@Override public int compare(CachedResource cr1, CachedResource cr2) { long nc1 = cr1.getNextCheck(); long nc2 = cr2.getNextCheck(); // Oldest resource should be first (so iterator goes from oldest to // youngest. if (nc1 == nc2) { return 0; } else if (nc1 > nc2) { return -1; } else { return 1; } } }
private long evict(long targetSize, Iterator<CachedResource> iter) { long now = System.currentTimeMillis(); long newSize = size.get(); while (newSize > targetSize && iter.hasNext()) { CachedResource resource = iter.next(); // Don't expire anything that has been checked within the TTL if (resource.getNextCheck() > now) { continue; } // Remove the entry from the cache removeCacheEntry(resource.getWebappPath()); newSize = size.get(); } return newSize; }
private long evict(long targetSize, Iterator<CachedResource> iter) { long now = System.currentTimeMillis(); long newSize = size.get(); while (newSize > targetSize && iter.hasNext()) { CachedResource resource = iter.next(); // Don't expire anything that has been checked within the TTL if (resource.getNextCheck() > now) { continue; } // Remove the entry from the cache removeCacheEntry(resource.getWebappPath()); newSize = size.get(); } return newSize; }
private long evict(long targetSize, Iterator<CachedResource> iter) { long now = System.currentTimeMillis(); long newSize = size.get(); while (newSize > targetSize && iter.hasNext()) { CachedResource resource = iter.next(); // Don't expire anything that has been checked within the TTL if (resource.getNextCheck() > now) { continue; } // Remove the entry from the cache removeCacheEntry(resource.getWebappPath(), true); newSize = size.get(); } return newSize; }