
Classes | |
| class | CacheEntry< ITEM_TYPE > |
Public Member Functions | |
| void | clear () |
| long | count () |
| ITEM_TYPE | get (ID_TYPE aId) |
| long | getCeilingSize () |
| int | getMaximumItems () |
| long | getMaximumSize () |
| long | getSize () |
| boolean | has (ID_TYPE aId) |
| Set< ID_TYPE > | keys () |
| LRUCache (final int maximumItems, final long maximumSize, final long ceilingSize) | |
| void | put (ID_TYPE aId, ITEM_TYPE aItem, long item_size) |
| void | remove (ID_TYPE key) |
Private Attributes | |
| long | ceilingSize |
| final Map< ID_TYPE, CacheEntry < ITEM_TYPE > > | items |
| int | maximumItems |
| final long | maximumSize |
| long | size = 0 |
Static Private Attributes | |
| static final int | INITIAL_TABLE_SIZE = 2048 |
| LRUCache | ( | final int | maximumItems, | |
| final long | maximumSize, | |||
| final long | ceilingSize | |||
| ) |
Caches are created as empty, and populated through use.
| maximumItems | maximum number of items allowed in the cache | |
| maximumSize | maximum size in bytes of the cache | |
| ceilingSize | number of bytes to attempt to leave as ceiling room |
Creates a linked hash map which expels old elements on declared criterion
| void clear | ( | ) |
Start from beginning, and remove all items from the cache; if cache is disabled, do nothing.
Forces a re-population of all items into the cache.
| long count | ( | ) |
| ITEM_TYPE get | ( | ID_TYPE | aId | ) |
Retrieve an existing item from the cache.
| aId | is non-null, and corresponds to an existing item in the cache. |
| IllegalArgumentException | if aId is null, or if the item is not in the cache | |
| IllegalStateException | if the item in the cache is null or the cache is disabled |
| long getCeilingSize | ( | ) |
| int getMaximumItems | ( | ) |
| long getMaximumSize | ( | ) |
| long getSize | ( | ) |
| boolean has | ( | ID_TYPE | aId | ) |
Return true only if the corresponding item is in the cache, and has been in it for no more that fRefreshInterval milliseconds; if caching is disabled, then always return false.
| aId | is non-null. |
| IllegalArgumentException | if a param does not comply. |
| Set<ID_TYPE> keys | ( | ) |
| void put | ( | ID_TYPE | aId, | |
| ITEM_TYPE | aItem, | |||
| long | item_size | |||
| ) |
If the item is already present, then replace it; otherwise, add it.
If the cache is disabled, do nothing.
| aId | is non-null | |
| aItem | is non-null | |
| item_size | is the size of aItem in bytes |
| IllegalArgumentException | if param does not comply |
| void remove | ( | ID_TYPE | key | ) |
Remove an entry from the cache
| key | the key for the entry |
long ceilingSize [private] |
final int INITIAL_TABLE_SIZE = 2048 [static, private] |
final Map<ID_TYPE, CacheEntry<ITEM_TYPE> > items [private] |
Map containing the actual storage
int maximumItems [private] |
final long maximumSize [private] |
long size = 0 [private] |
1.5.8