public class ObjectCache extends Object implements ObjectCacheManager
ObjectCacheManager interface
they only have to provide their own functionality whilst client classes can rely on the
interface. All operations defined with ObjectCacheManager are supported here.| 构造器和说明 |
|---|
ObjectCache(int policy) |
| 限定符和类型 | 方法和说明 |
|---|---|
ObjectCache |
cacheSlice(Date from,
Date to) |
ObjectCache |
cacheSliceFrom(Date from) |
ObjectCache |
cacheSliceTo(Date to) |
int |
capacity()
Return the current capacity of the cache, it should basically be (max size - current size).
|
boolean |
containsKey(Object key) |
Object |
firstKey() |
Object |
firstValue() |
void |
flush()
Clear our data structures.
|
Object |
get(Object key) |
Date |
getLastAccessTime(Object key) |
int |
getMaxSize() |
int |
getPolicy() |
boolean |
isEmpty()
Return whether the cache is empty or not.
|
Iterator |
iterator() |
List |
keys()
Return a List of all the keys in the cache.
|
List |
keys(GeneralFilter f) |
List |
keysForFilteredValues(GeneralFilter f) |
void |
keysToList(List list) |
Object |
lastValue() |
void |
merge(ObjectCache cache)
Merge the current cache with another.
|
void |
put(Object key,
Object value) |
void |
putAll(Map map)
Add all the entries in the Map to cache.
|
void |
remove(Object key) |
protected void |
resize() |
void |
resize(int size)
Resize the cache to a particular size, if the size is actually bigger than the
current size then this operation should not touch the cached objects, if the size is
less then the cache should be reduced in size using the current policy until the
size is reached.
|
void |
setMaxSize(int size)
Set the maximum size of the cache.
|
void |
setPolicy(int type) |
int |
size() |
Map |
slice(Date from,
Date to) |
Map |
sliceFrom(Date from) |
Map |
sliceTo(Date to) |
void |
toMap(Map map)
Get all the entries in the cache as a Map of key to value.
|
List |
values()
Return a List of all the values in the cache.
|
List |
values(GeneralFilter f) |
void |
valuesToList(List list) |
public static final int OLDEST
public static final int YOUNGEST
public static final int RANDOM
public ObjectCache(int policy)
throws IllegalArgumentException
public void setPolicy(int type)
throws IllegalArgumentException
setPolicy 在接口中 ObjectCacheManagerIllegalArgumentExceptionpublic int getPolicy()
public Iterator iterator()
public List keys()
public List values()
public List keysForFilteredValues(GeneralFilter f) throws IllegalAccessException, InvocationTargetException, FilterException
public List values(GeneralFilter f) throws IllegalAccessException, InvocationTargetException, FilterException
public List keys(GeneralFilter f) throws IllegalAccessException, InvocationTargetException, FilterException
public void valuesToList(List list)
public void keysToList(List list)
public void toMap(Map map)
ObjectCacheManagertoMap 在接口中 ObjectCacheManagermap - The Map that should be populated with the key/values in the cache.public void putAll(Map map)
ObjectCacheManagerputAll 在接口中 ObjectCacheManagermap - The Map to get key/values from.public boolean containsKey(Object key)
public void merge(ObjectCache cache)
ObjectCacheManagermerge 在接口中 ObjectCacheManagercache - The cache to merge.public ObjectCache cacheSliceTo(Date to)
public ObjectCache cacheSliceFrom(Date from)
public ObjectCache cacheSlice(Date from, Date to)
public boolean isEmpty()
ObjectCacheManagerisEmpty 在接口中 ObjectCacheManagertrue if the cache is empty, false if it has entries.public int capacity()
ObjectCacheManagercapacity 在接口中 ObjectCacheManagerpublic int getMaxSize()
public void setMaxSize(int size)
ObjectCacheManagersetMaxSize 在接口中 ObjectCacheManagersize - The maximum size.public Object firstValue()
public Object lastValue()
public Object firstKey()
public int size()
public void remove(Object key)
public void resize(int size)
ObjectCacheManagerresize 在接口中 ObjectCacheManagersize - The new size.protected void resize()
public void flush()
flush 在接口中 ObjectCacheManagerCopyright © 2021. All rights reserved.