com.opensymphony.oscache.base.algorithm
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Nested Class Summary | |
|---|---|
protected static class |
AbstractConcurrentReadCache.Entry
AbstractConcurrentReadCache collision list entry. |
protected class |
AbstractConcurrentReadCache.HashIterator
|
protected class |
AbstractConcurrentReadCache.KeyIterator
|
protected class |
AbstractConcurrentReadCache.ValueIterator
|
| Field Summary | |
|---|---|
protected Boolean |
barrierLock
Lock used only for its memory effects. |
protected int |
count
The total number of mappings in the hash table. |
static int |
DEFAULT_INITIAL_CAPACITY
The default initial number of table slots for this table (32). |
static float |
DEFAULT_LOAD_FACTOR
The default load factor for this table. |
protected int |
DEFAULT_MAX_ENTRIES
Default cache capacity (number of entries). |
protected Set |
entrySet
|
protected HashMap |
groups
A HashMap containing the group information. |
protected Set |
keySet
|
protected Object |
lastWrite
field written to only to guarantee lock ordering. |
protected float |
loadFactor
The load factor for the hash table. |
protected int |
maxEntries
Cache capacity (number of entries). |
protected boolean |
memoryCaching
Use memory cache or not. |
protected static String |
NULL
|
protected PersistenceListener |
persistenceListener
Persistence listener. |
protected AbstractConcurrentReadCache.Entry[] |
table
The hash table data. |
protected int |
threshold
The table is rehashed when its size exceeds this threshold. |
protected int |
UNLIMITED
Max number of element in cache when considered unlimited. |
protected boolean |
unlimitedDiskCache
Use unlimited disk caching. |
protected Collection |
values
|
| Constructor Summary | |
|---|---|
AbstractConcurrentReadCache()
Constructs a new, empty map with a default initial capacity and load factor. |
|
AbstractConcurrentReadCache(int initialCapacity)
Constructs a new, empty map with the specified initial capacity and default load factor. |
|
AbstractConcurrentReadCache(int initialCapacity,
float loadFactor)
Constructs a new, empty map with the specified initial capacity and the specified load factor. |
|
AbstractConcurrentReadCache(Map t)
Constructs a new map with the same mappings as the given map. |
|
| Method Summary | |
|---|---|
int |
capacity()
Return the number of slots in this table. |
void |
clear()
Removes all mappings from this map. |
Object |
clone()
Returns a shallow copy of this. |
boolean |
contains(Object value)
Tests if some key maps into the specified value in this table. |
boolean |
containsKey(Object key)
Tests if the specified object is a key in this table. |
boolean |
containsValue(Object value)
Returns true if this map maps one or more keys to the specified value. |
Enumeration |
elements()
Returns an enumeration of the values in this table. |
Set |
entrySet()
Returns a collection view of the mappings contained in this map. |
protected boolean |
findAndRemoveEntry(Map.Entry entry)
Helper method for entrySet remove. |
Object |
get(Object key)
Returns the value to which the specified key is mapped in this table. |
Set |
getGroup(String groupName)
Returns a set of the cache keys that reside in a particular group. |
protected Set |
getGroupForReading(String groupName)
Get ref to group. |
protected Map |
getGroupsForReading()
Get ref to groups. |
int |
getMaxEntries()
Retrieve the cache capacity (number of entries). |
PersistenceListener |
getPersistenceListener()
Get the persistence listener. |
protected AbstractConcurrentReadCache.Entry[] |
getTableForReading()
Get ref to table; the reference and the cells it accesses will be at least as fresh as from last use of barrierLock |
boolean |
isEmpty()
Returns true if this map contains no key-value mappings. |
boolean |
isMemoryCaching()
Check if memory caching is used. |
boolean |
isOverflowPersistence()
Check if we use overflowPersistence |
boolean |
isUnlimitedDiskCache()
Check if we use unlimited disk cache. |
protected abstract void |
itemPut(Object key)
Notify the underlying implementation that an item was put in the cache. |
protected abstract void |
itemRemoved(Object key)
Notify the underlying implementation that an item was removed from the cache. |
protected abstract void |
itemRetrieved(Object key)
Notify any underlying algorithm that an item has been retrieved from the cache. |
Enumeration |
keys()
Returns an enumeration of the keys in this table. |
Set |
keySet()
Returns a set view of the keys contained in this map. |
float |
loadFactor()
Return the load factor |
protected void |
persistClear()
Removes the entire cache from persistent storage. |
protected void |
persistRemove(Object key)
Remove an object from the persistence. |
protected void |
persistRemoveGroup(String groupName)
Removes a cache group using the persistence listener. |
protected Object |
persistRetrieve(Object key)
Retrieve an object from the persistence listener. |
protected Set |
persistRetrieveGroup(String groupName)
Retrieves a cache group using the persistence listener. |
protected void |
persistStore(Object key,
Object obj)
Store an object in the cache using the persistence listener. |
protected void |
persistStoreGroup(String groupName,
Set group)
Creates or Updates a cache group using the persistence listener. |
Object |
put(Object key,
Object value)
OpenSymphony BEGIN |
void |
putAll(Map t)
Copies all of the mappings from the specified map to this one. |
protected void |
recordModification(Object x)
Force a memory synchronization that will cause all readers to see table. |
protected void |
rehash()
Rehashes the contents of this map into a new table with a larger capacity. |
Object |
remove(Object key)
OpenSymphony BEGIN |
Object |
removeForce(Object key)
Like remove(Object), but ensures that the entry will be removed from the persistent store, too,
even if overflowPersistence or unlimitedDiskcache are true. |
protected abstract Object |
removeItem()
The cache has reached its cacpacity and an item needs to be removed. |
void |
setMaxEntries(int newLimit)
Set the cache capacity |
void |
setMemoryCaching(boolean memoryCaching)
Sets the memory caching flag. |
void |
setOverflowPersistence(boolean overflowPersistence)
Sets the overflowPersistence flag |
void |
setPersistenceListener(PersistenceListener listener)
Set the persistence listener to use. |
void |
setUnlimitedDiskCache(boolean unlimitedDiskCache)
Sets the unlimited disk caching flag. |
int |
size()
Returns the total number of cache entries held in this map. |
protected Object |
sput(Object key,
Object value,
int hash,
boolean persist)
OpenSymphony BEGIN |
protected Object |
sremove(Object key,
int hash,
boolean invokeAlgorithm)
OpenSymphony BEGIN |
Collection |
values()
Returns a collection view of the values contained in this map. |
| Methods inherited from class java.util.AbstractMap |
|---|
equals, hashCode, toString |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Map |
|---|
equals, hashCode |
| Field Detail |
|---|
public static final int DEFAULT_INITIAL_CAPACITY
public static final float DEFAULT_LOAD_FACTOR
protected static final String NULL
protected final Boolean barrierLock
protected transient Object lastWrite
protected transient AbstractConcurrentReadCache.Entry[] table
protected transient int count
protected transient PersistenceListener persistenceListener
protected boolean memoryCaching
protected boolean unlimitedDiskCache
protected float loadFactor
protected final int DEFAULT_MAX_ENTRIES
protected final int UNLIMITED
protected transient Collection values
protected HashMap groups
Set of containing keys of all
the cache entries that belong to that particular group.
protected transient Set entrySet
protected transient Set keySet
protected int maxEntries
protected int threshold
| Constructor Detail |
|---|
public AbstractConcurrentReadCache(int initialCapacity,
float loadFactor)
initialCapacity - the initial capacity
The actual initial capacity is rounded to the nearest power of two.loadFactor - the load factor of the AbstractConcurrentReadCache
IllegalArgumentException - if the initial maximum number
of elements is less
than zero, or if the load factor is nonpositive.public AbstractConcurrentReadCache(int initialCapacity)
initialCapacity - the initial capacity of the
AbstractConcurrentReadCache.
IllegalArgumentException - if the initial maximum number
of elements is less
than zero.public AbstractConcurrentReadCache()
public AbstractConcurrentReadCache(Map t)
| Method Detail |
|---|
public boolean isEmpty()
isEmpty in interface MapisEmpty in class AbstractMappublic Set getGroup(String groupName)
groupName - The name of the group to retrieve.
null if the group was not found.
NullPointerException - if the groupName is null.public void setMaxEntries(int newLimit)
public int getMaxEntries()
public void setMemoryCaching(boolean memoryCaching)
public boolean isMemoryCaching()
public void setPersistenceListener(PersistenceListener listener)
public PersistenceListener getPersistenceListener()
public void setUnlimitedDiskCache(boolean unlimitedDiskCache)
public boolean isUnlimitedDiskCache()
public boolean isOverflowPersistence()
public void setOverflowPersistence(boolean overflowPersistence)
overflowPersistence - The overflowPersistence to set.public int capacity()
public void clear()
clear in interface Mapclear in class AbstractMappublic Object clone()
clone in class AbstractMappublic boolean contains(Object value)
containsKey
method.Note that this method is identical in functionality to containsValue, (which is part of the Map interface in the collections framework).
value - a value to search for.
true if and only if some key maps to the
value argument in this table as
determined by the equals method;
false otherwise.
NullPointerException - if the value is null.containsKey(Object),
containsValue(Object),
Mappublic boolean containsKey(Object key)
containsKey in interface MapcontainsKey in class AbstractMapkey - possible key.
true if and only if the specified object
is a key in this table, as determined by the
equals method; false otherwise.
NullPointerException - if the key is
null.contains(Object)public boolean containsValue(Object value)
containsValue in interface MapcontainsValue in class AbstractMapvalue - value whose presence in this map is to be tested.
NullPointerException - if the value is null.public Enumeration elements()
Enumeration,
keys(),
values(),
Mappublic Set entrySet()
entrySet in interface MapentrySet in class AbstractMappublic Object get(Object key)
get in interface Mapget in class AbstractMapkey - a key in the table.
null if the key is not mapped to any value in
this table.
NullPointerException - if the key is
null.put(Object, Object)public Set keySet()
keySet in interface MapkeySet in class AbstractMappublic Enumeration keys()
Enumeration,
elements(),
keySet(),
Mappublic float loadFactor()
public Object put(Object key, Object value)
put in interface Mapput in class AbstractMappublic void putAll(Map t)
putAll in interface MapputAll in class AbstractMapt - Mappings to be stored in this map.public Object remove(Object key)
remove in interface Mapremove in class AbstractMappublic Object removeForce(Object key)
remove(Object), but ensures that the entry will be removed from the persistent store, too,
even if overflowPersistence or unlimitedDiskcache are true.
key - the key that needs to be removed.
null if the key did not have a mapping.public int size()
size in interface Mapsize in class AbstractMappublic Collection values()
values in interface Mapvalues in class AbstractMapprotected final Set getGroupForReading(String groupName)
protected final Map getGroupsForReading()
protected final AbstractConcurrentReadCache.Entry[] getTableForReading()
protected final void recordModification(Object x)
protected boolean findAndRemoveEntry(Map.Entry entry)
protected void persistRemove(Object key)
key - The key of the object to removeprotected void persistRemoveGroup(String groupName)
groupName - The name of the group to removeprotected Object persistRetrieve(Object key)
key - The key of the object to retrieveprotected Set persistRetrieveGroup(String groupName)
groupName - The name of the group to retrieveprotected void persistStore(Object key, Object obj)
key - The object keyobj - The object to storeprotected void persistStoreGroup(String groupName, Set group)
groupName - The name of the group to updategroup - The entries for the groupprotected void persistClear()
protected abstract void itemPut(Object key)
key - The cache key of the item that was put.protected abstract void itemRetrieved(Object key)
key - The cache key of the item that was retrieved.protected abstract void itemRemoved(Object key)
key - The cache key of the item that was removed.protected abstract Object removeItem()
protected void rehash()
protected Object sput(Object key, Object value, int hash, boolean persist)
protected Object sremove(Object key, int hash, boolean invokeAlgorithm)
|
OSCache Project Page | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||