jodd.cache
Class FIFOCache<K,V>
java.lang.Object
jodd.cache.AbstractCacheMap<K,V>
jodd.cache.FIFOCache<K,V>
- All Implemented Interfaces:
- Cache<K,V>
public class FIFOCache<K,V>
- extends AbstractCacheMap<K,V>
FIFO (first in first out) cache.
FIFO (first in first out): just adds items to the cache as they are accessed, putting them in a queue or buffer and
not changing their location in the buffer; when the cache is full, items are ejected in the order they were
added. Cache access overhead is constant time regardless of the size of the cache. The advantage of this algorithm
is that it's simple and fast; it can be implemented using a simple array and an index. The disadvantage is that
it's not very smart; it doesn't make any effort to keep more commonly used items in cache.
Summary for FIFO: fast, not adaptive, not scan resistant
Constructor Summary |
FIFOCache(int cacheSize)
|
FIFOCache(int cacheSize,
long timeout)
Creates a new LRU cache. |
Method Summary |
int |
prune()
Prune expired objects and, if cache is still full, the first one. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FIFOCache
public FIFOCache(int cacheSize)
FIFOCache
public FIFOCache(int cacheSize,
long timeout)
- Creates a new LRU cache.
prune
public int prune()
- Prune expired objects and, if cache is still full, the first one.
- Specified by:
prune
in interface Cache<K,V>
- Specified by:
prune
in class AbstractCacheMap<K,V>
Copyright ©2008 Jodd Team