我想創建一個有效的LRU緩存實現。我發現最方便的方法是使用LinkedHashMap,但不幸的是,如果許多線程正在使用緩存,它會很慢。我的實現是在這裏: /**
* Class provides API for FixedSizeCache.
* Its inheritors represent classes
* with concrete strategies
* for cho
我現在有一個自定義類,看起來數組一樣: Phy[] memory = new Phy[256];
在我的Phy類,我有以下功能: 獲取時間戳(返回時間戳) 更新時間標記(使用系統時,獲取MS自1970年以來,並將其設置) 當涉及到LRU部分找到LRU類我做的: public int getLeastRecentlyUsed(){
long leastUsed = memory[0].
我正在爲用戶的照片實現一個LRU緩存,使用Commons Collections LRUMap(基本上是一個帶有小修改的LinkedHashMap)。 findPhoto方法可以在幾秒鐘內調用幾百次。 public class CacheHandler {
private static final int MAX_ENTRIES = 1000;
private static M