public class LruObjectCache extends Object implements ObjectCache
Dao.setObjectCache(ObjectCache)
.
NOTE: If you set the capacity to be 100 then each Class will allow 100 items in the cache. If you have 5 classes then the cache will hold 500 objects.
Constructor and Description |
---|
LruObjectCache(int capacity) |
Modifier and Type | Method and Description |
---|---|
<T> void |
clear(Class<T> clazz)
Remove all entries from the cache of a certain class.
|
void |
clearAll()
Remove all entries from the cache of all classes.
|
<T,ID> T |
get(Class<T> clazz,
ID id)
Lookup in the cache for an object of a certain class that has a certain id.
|
<T,ID> void |
put(Class<T> clazz,
ID id,
T data)
Put an object in the cache that has a certain class and id.
|
<T> void |
registerClass(Class<T> clazz)
Register a class for use with this class.
|
<T,ID> void |
remove(Class<T> clazz,
ID id)
Delete from the cache an object of a certain class that has a certain id.
|
<T> int |
size(Class<T> clazz)
Return the number of elements in the cache.
|
int |
sizeAll()
Return the number of elements in all of the caches.
|
<T,ID> T |
updateId(Class<T> clazz,
ID oldId,
ID newId)
Change the id in the cache for an object of a certain class from an old-id to a new-id.
|
public <T> void registerClass(Class<T> clazz)
ObjectCache
registerClass
in interface ObjectCache
public <T,ID> T get(Class<T> clazz, ID id)
ObjectCache
get
in interface ObjectCache
public <T,ID> void put(Class<T> clazz, ID id, T data)
ObjectCache
put
in interface ObjectCache
public <T> void clear(Class<T> clazz)
ObjectCache
clear
in interface ObjectCache
public void clearAll()
ObjectCache
clearAll
in interface ObjectCache
public <T,ID> void remove(Class<T> clazz, ID id)
ObjectCache
remove
in interface ObjectCache
public <T,ID> T updateId(Class<T> clazz, ID oldId, ID newId)
ObjectCache
updateId
in interface ObjectCache
public <T> int size(Class<T> clazz)
ObjectCache
size
in interface ObjectCache
public int sizeAll()
ObjectCache
sizeAll
in interface ObjectCache
This documentation is licensed by Gray Watson under the Creative Commons Attribution-Share Alike 3.0 License.