public long free(long toFree) { Map.Entry<BlockCacheKey, BucketEntry> entry; long freedBytes = 0; // TODO avoid a cycling siutation. We find no block which is not in use and so no way to free // What to do then? Caching attempt fail? Need some changes in cacheBlock API? while ((entry = queue.pollLast()) != null) { if (evictBlock(entry.getKey(), false)) { freedBytes += entry.getValue().getLength(); } if (freedBytes >= toFree) { return freedBytes; } } return freedBytes; }
public long free(long toFree) { Map.Entry<BlockCacheKey, BucketEntry> entry; long freedBytes = 0; while ((entry = queue.pollLast()) != null) { evictBlock(entry.getKey()); freedBytes += entry.getValue().getLength(); if (freedBytes >= toFree) { return freedBytes; } } return freedBytes; }