public int get(int key) { CacheItem<Integer, Integer> itm = cacheMap.get(key); if (itm == null) return -1; cacheList.delete(itm); cacheList.insertTail(itm); return itm.value.intValue(); }
private void updateItem(int key, int value) { CacheItem<Integer, Integer> exitedKey = cacheMap.get(key); exitedKey.value = value; cacheList.delete(exitedKey); cacheList.insertTail(exitedKey); }