001package org.apache.commons.jcs.engine.memory.fifo;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *   http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import java.io.IOException;
023
024import org.apache.commons.jcs.engine.behavior.ICacheElement;
025import org.apache.commons.jcs.engine.memory.AbstractDoubleLinkedListMemoryCache;
026import org.apache.commons.jcs.engine.memory.util.MemoryElementDescriptor;
027
028/**
029 * The items are spooled in the order they are added. No adjustments to the list are made on get.
030 */
031public class FIFOMemoryCache<K, V>
032    extends AbstractDoubleLinkedListMemoryCache<K, V>
033{
034    /**
035     * Puts an item to the cache. Removes any pre-existing entries of the same key from the linked
036     * list and adds this one first.
037     * <p>
038     * @param ce The cache element, or entry wrapper
039     * @return MemoryElementDescriptor the new node
040     * @throws IOException
041     */
042    @Override
043    protected MemoryElementDescriptor<K, V> adjustListForUpdate( ICacheElement<K, V> ce )
044        throws IOException
045    {
046        return addFirst( ce );
047    }
048
049    /**
050     * Does nothing.
051     * <p>
052     * @param me
053     */
054    @Override
055    protected void adjustListForGet( MemoryElementDescriptor<K, V> me )
056    {
057        // DO NOTHING
058    }
059}