|
uPortal 2.4.1 API Documentation |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractMap
java.util.HashMap
org.jasig.portal.concurrency.caching.LRUCache
A rewrite of SmartCache that uses a moderate LRU algorithm: entries are purged from the cache via periodic sweeps rather than in response to specific cache additions. Note that sweeps have to be kicked off externally, e.g.,
int MAX_CACHE_SIZE = 1000;
int MAX_UNUSED_TIME_MILLIS = 30*60*1000;
LRUCache cache = new LRUCache(MAX_CACHE_SIZE, MAX_UNUSED_TIME_MILLIS);
// ... put stuff in ...
cache.sweepCache()
// ... put more stuff in ...
At the end of the sweep, the cache will have no more (and possibly less)
than maxSize
entries, though the sweep may have to reduce
maxUnusedTimeMillis
in order to get there.
SmartCache
,
Serialized FormConstructor Summary | |
LRUCache()
|
|
LRUCache(int size)
|
|
LRUCache(int size,
int maxUnusedAge)
|
Method Summary | |
void |
clear()
Synchronizes removal of ALL entries from the cache. |
java.lang.Object |
get(java.lang.Object key)
Get the object from the cache and reset the timestamp. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Add a new value to the cache. |
java.lang.Object |
remove(java.lang.Object key)
Synchronizes removal of an entry from the cache. |
void |
sweepCache()
Sweep the cache until it gets back under maxSize . |
Methods inherited from class java.util.HashMap |
clone, containsKey, containsValue, entrySet, isEmpty, keySet, putAll, size, values |
Methods inherited from class java.util.AbstractMap |
equals, hashCode, toString |
Methods inherited from class java.lang.Object |
getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
equals, hashCode |
Constructor Detail |
public LRUCache()
public LRUCache(int size)
public LRUCache(int size, int maxUnusedAge)
size
- intmaxUnusedAge
- intMethod Detail |
public void clear()
public java.lang.Object get(java.lang.Object key)
key
- the key, typically a String
public java.lang.Object put(java.lang.Object key, java.lang.Object value)
key
- the key, typically a Stringvalue
- the value
public java.lang.Object remove(java.lang.Object key)
key
- the key, typically a String
public void sweepCache()
maxSize
.
|
uPortal 2.4.1 API Documentation |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |