1 5 package com.opensymphony.oscache.base.algorithm; 6 7 import java.util.*; 8 9 21 public class FIFOCache extends AbstractConcurrentReadCache { 22 23 26 private Collection list = new LinkedHashSet(); 27 28 31 public FIFOCache() { 32 super(); 33 } 34 35 40 public FIFOCache(int capacity) { 41 this(); 42 maxEntries = capacity; 43 } 44 45 51 protected void itemRetrieved(Object key) { 52 } 53 54 61 protected void itemPut(Object key) { 62 if (!list.contains(key)) { 63 list.add(key); 64 } 65 } 66 67 74 protected Object removeItem() { 75 Iterator it = list.iterator(); 76 Object toRemove = it.next(); 77 it.remove(); 78 79 return toRemove; 80 } 81 82 87 protected void itemRemoved(Object key) { 88 list.remove(key); 89 } 90 } 91 | Popular Tags |