示例#1
0
  private CacheElement put(long address) throws IOException {
    /** get a CacheElement from the stack object pool */
    CacheElement c = map.pop();

    /** read the element from the device */
    c.read(address);

    /** and insert the element into the LinkedHashMap */
    map.put(c);

    /**
     * stack "must" contains at least one entry the placeholder ... so let it throw an exception if
     * this is false
     */
    CacheElement e = map.peek();
    // if an element was discarded from the LRU cache
    // now we can free it ... this will send the element
    // to storage if is marked as dirty
    if (!e.isFree()) e.free();

    return c;
  }