org.mentawai.cache
Class AbstractCache

java.lang.Object
  extended by org.mentawai.cache.AbstractCache
All Implemented Interfaces:
Serializable, Cache
Direct Known Subclasses:
FIFOCache, LRUCache, TimeoutCache

public abstract class AbstractCache
extends Object
implements Cache, Serializable

See Also:
Serialized Form

Field Summary
protected  int capacity
           
protected  int hits
           
protected static float LOAD
           
protected  Map<Object,Object> map
           
protected  int misses
           
protected  String name
           
protected  Date startDate
           
 
Constructor Summary
AbstractCache(String name, int capacity)
           
AbstractCache(String name, int capacity, float load)
           
 
Method Summary
 void clear()
           
protected abstract  Map<Object,Object> createMap(int initialCapacity, float load)
           
 Object get(Object key)
           
 int getSize()
           
 Object put(Object key, Object value)
           
 Object remove(Object key)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LOAD

protected static final float LOAD
See Also:
Constant Field Values

name

protected final String name

map

protected final Map<Object,Object> map

capacity

protected final int capacity

misses

protected transient volatile int misses

hits

protected transient volatile int hits

startDate

protected final transient Date startDate
Constructor Detail

AbstractCache

public AbstractCache(String name,
                     int capacity)

AbstractCache

public AbstractCache(String name,
                     int capacity,
                     float load)
Method Detail

createMap

protected abstract Map<Object,Object> createMap(int initialCapacity,
                                                float load)

remove

public Object remove(Object key)
Specified by:
remove in interface Cache

get

public Object get(Object key)
Specified by:
get in interface Cache

put

public Object put(Object key,
                  Object value)
Specified by:
put in interface Cache

clear

public void clear()
Specified by:
clear in interface Cache

getSize

public int getSize()

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2013. All Rights Reserved.