There are two things I was very uncertain about with this task... First, the removeEldestEntry method in the LRUCache class doesn't actually appear to do what it is supposed to do, but we were not instructed to edit that class, so I didn't touch it. And the constructor for this class takes a capacity argument, however I have no idea what that value should be. I just picked 10 and hoped it would work.
I don't know if either of those are related to why the task won't pass.
package com.codegym.task.task37.task3708;
import com.codegym.task.task37.task3708.retrievers.CachingProxyRetriever;
import com.codegym.task.task37.task3708.retrievers.OriginalRetriever;
import com.codegym.task.task37.task3708.retrievers.Retriever;
import com.codegym.task.task37.task3708.storage.RemoteStorage;
import com.codegym.task.task37.task3708.storage.Storage;
/*
Caching proxy
*/
public class Solution {
private static final int n = 10;
public static void main(String[] args) {
Storage storage = new RemoteStorage();
fillStorage(storage);
System.out.println("Testing OriginalRetriever: ");
testRetriever(new OriginalRetriever(storage));
System.out.println("\n\n\n\n\n\n\n\n\n\nTesting CachingProxyRetriever: ");
testRetriever(new CachingProxyRetriever(storage));
}
private static void fillStorage(Storage storage) {
for (int i = 0; i < n; i++) {
storage.add("Resource #" + i);
}
}
private static void testRetriever(Retriever retriever) {
for (int i = 0; i < n; i++) {
System.out.println("Loaded value : " + retriever.retrieve((long) (Math.random() * n)));
}
}
}