Cache
The cache keeps frequently used objects in the main memory.
| Methods |
| void |
clear()
Clear the cache.
|
| void |
clear()
Clear the cache.
|
| CacheObject |
find(int pos)
Get an element from the cache if it is available.
|
| CacheObject |
find(int pos)
Get an element from the cache if it is available.
This will not move the item to the front of the list.
Parameters:
pos - the unique key of the element
Returns:
the element or null
|
| CacheObject |
get(int pos)
Get an element in the cache if it is available.
|
| CacheObject |
get(int pos)
Get an element in the cache if it is available.
This will move the item to the front of the list.
Parameters:
pos - the unique key of the element
Returns:
the element or null
|
| ArrayList |
getAllChanged()
Get all objects in the cache that have been changed.
|
| ArrayList |
getAllChanged()
Get all objects in the cache that have been changed.
Returns:
the list of objects
|
| int |
getMaxMemory()
Get the maximum memory to be used.
|
| int |
getMaxMemory()
Get the maximum memory to be used.
Returns:
the maximum size in KB
|
| int |
getMemory()
Get the used size in KB.
|
| int |
getMemory()
Get the used size in KB.
Returns:
the current size in KB
|
| void |
put(CacheObject r)
Add an element to the cache.
|
| void |
put(CacheObject r)
Add an element to the cache. Other items may fall out of the cache
because of this. It is not allowed to add the same record twice.
Parameters:
r - the object
|
| boolean |
remove(int pos)
Remove an object from the cache.
|
| boolean |
remove(int pos)
Remove an object from the cache.
Parameters:
pos - the unique key of the element
Returns:
true if the key was in the cache
|
| void |
setMaxMemory(int size)
Set the maximum memory to be used by this cache.
|
| void |
setMaxMemory(int size)
Set the maximum memory to be used by this cache.
Parameters:
size - the maximum size in KB
|
| CacheObject |
update(int pos, CacheObject record)
Update an element in the cache.
|
| CacheObject |
update(int pos, CacheObject record)
Update an element in the cache.
This will move the item to the front of the list.
Parameters:
pos - the unique key of the element
record - the element
Returns:
the element
|