Code example for LinkedHashMap

Methods: get, put

0
    } 
 
    private synchronized Editor edit(String key, long expectedSequenceNumber) throws IOException {
        checkNotClosed(); 
        validateKey(key);
        Entry entry = lruEntries.get(key);
        if (expectedSequenceNumber != ANY_SEQUENCE_NUMBER
                && (entry == null || entry.sequenceNumber != expectedSequenceNumber)) {
            return null; // snapshot is stale 
        } 
        if (entry == null) {
            entry = new Entry(key);
            lruEntries.put(key, entry);
        } else if (entry.currentEditor != null) {
            return null; // another edit is in progress 
        } 
 
        Editor editor = new Editor(entry);
        entry.currentEditor = editor;
 
        // flush the journal before creating files to prevent file leaks