net.obsearch.cache
Class OBCacheLong<O>
java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap<K,V>
java.util.LinkedHashMap<K,O>
net.obsearch.cache.AbstractOBCache<Long,O>
net.obsearch.cache.OBCacheLong<O>
- Type Parameters:
O
- The type of object that will be stored in the Cache.
- All Implemented Interfaces:
- Serializable, Cloneable, Map<Long,O>
public final class OBCacheLong<O>
- extends AbstractOBCache<Long,O>
By using soft references, an OB cache is implemented The garbage collector
decides based on the access patterns of each reference, which elements are
released and which are kept. The cache controls the loading of items. For
this purpose an OBCacheLoader is provided to control the loading and
instantiation of the objects from secondary storage. That is why this cache
does not have a put method. It assumes that all the requested items exist
in secondary storage otherwise it returns an error. Loading operations
generate a lock but reading operations do not generate any locks.
- Since:
- 0.7
- Author:
- Arnoldo Jose Muller Molina
- See Also:
- Serialized Form
Method Summary |
void |
clearAll()
Makes sure the cache is cleaned and each
object is stored. |
O |
get(long id)
Gets the given object, returns null if the object is not found. |
protected boolean |
removeEldestEntry(Map.Entry<Long,O> eldest)
|
Methods inherited from interface java.util.Map |
containsKey, entrySet, equals, hashCode, isEmpty, keySet, put, putAll, remove, size, values |
OBCacheLong
public OBCacheLong(OBCacheHandlerLong<O> handler,
int cacheSize)
throws OBException
- Initialize the cache with the given amount of elements.
- Parameters:
size
- Number of elements that the internal hash table will be
initialized with.
- Throws:
OBException
get
public O get(long id)
throws OutOfRangeException,
OBException,
InstantiationException,
IllegalAccessException
- Gets the given object, returns null if the object is not found.
- Parameters:
id
- internal id.
- Returns:
- null if no object is found
- Throws:
OutOfRangeException
OBException
InstantiationException
IllegalAccessException
removeEldestEntry
protected boolean removeEldestEntry(Map.Entry<Long,O> eldest)
- Overrides:
removeEldestEntry
in class LinkedHashMap<Long,O>
clearAll
public void clearAll()
throws OBException
- Description copied from class:
AbstractOBCache
- Makes sure the cache is cleaned and each
object is stored.
- Specified by:
clearAll
in class AbstractOBCache<Long,O>
- Throws:
OBException
Copyright © 2007-2011 Arnoldo Jose Muller Molina. All Rights Reserved.