|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface CachedMap
Extends the Map interface to support expiration of old
entries. The map has a default expiration time, which is used for objects put
into the map without an explicit expiration frequency. The maximum expiration
time specifies the longest possible expiration time for the map. Its value
may affect the performance of the map and should be realistic. Expired
entries are searched at regular intervals specified by the expiration sleep
interval. All times are given in seconds. The value -1 indicates always
infinite time.
The expiration time of an entry is automatically refreshed when it is got from the map if not explicitly declined. However, iterators do not need to refresh entries accessed through them.
The maximum number of entries accepted by the map can be specified with max entries. The oldest entries above the limit will be expired indepently on their expiration time. The limit need not to be strict during puts but maintained by the expiration handler.
Note that the size of the map and its sets and collections is not constant in time as entries expire dynamically. Iterators can return expired entries if there is a pause between calls to the hasNext and next methods.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface java.util.Map |
|---|
Map.Entry<K,V> |
| Method Summary | |
|---|---|
boolean |
add(Object key,
Object obj)
Adds a cachable object into the map but only if the specified key is not already mapped. |
boolean |
add(Object key,
Object obj,
int freq)
Adds a cachable object into the map with an object specific expiration frequency but only if the specified key is not already mapped. |
Object |
expire(Object key)
Expires and removes an entry. |
void |
expireAll()
Expires all entries. |
void |
expireFraction(float fraction)
Expires a fraction of entries. |
Object |
get(Object key,
int freq)
Gets an object from the map and refreshes it with a specific expiration frequency. |
int |
getDefaultExpirationTime()
Gets the default expiration time in seconds. |
int |
getExpirationLimit()
Gets the expiration limit for the number of cached entries. |
int |
getExpirationSleepInterval()
Gets the expiration sleep interval in seconds. |
float |
getExpirationThreshold()
Gets the threshold relative to the entry limit before expiration of excessive entries starts. |
int |
getMaxExpirationTime()
Gets the maximum expiration time in seconds. |
boolean |
isAllowExpired()
Gets the allow expired option. |
boolean |
isAutoRefreshDeclined()
Gets the automatic refresh declined option. |
boolean |
isDiscardOverloaded()
Gets the discard overloaded option. |
Object |
put(Object key,
Object obj,
int freq)
Puts a cachable object into the map with an object specific expiration frequency. |
Object |
putIfAbsent(Object key,
Object obj,
int freq)
Puts a cachable object into the map with an object specific expiration frequency but only if the specified key is not already mapped. |
boolean |
refresh(Object key)
Refreshes an entry. |
boolean |
refresh(Object key,
int freq)
Refreshes an entry with a new frequency. |
void |
setAllowExpired(boolean flag)
Sets the allow expired option allowing gets of entries already expired but not yet removed by the expiration handler. |
void |
setAutoRefreshDeclined(boolean flag)
Sets the automatic refresh declined option preventing cached entries being automatically refreshed during plain gets. |
void |
setDefaultExpirationTime(int t)
Sets the default expiration time in seconds. |
void |
setDiscardOverloaded(boolean flag)
Sets the discard overloaded option. |
void |
setExpirationLimit(int c)
Sets the expiration limit for the number of cached entries. |
void |
setExpirationSleepInterval(int t)
Sets the expiration sleep interval in seconds. |
void |
setExpirationThreshold(float h)
Sets the threshold relative to the entry limit before expiration of excessive entries starts. |
void |
setMaxExpirationTime(int t)
Sets the maximum expiration time in seconds. |
| Methods inherited from interface java.util.concurrent.ConcurrentMap |
|---|
putIfAbsent, remove, replace, replace |
| Methods inherited from interface java.util.Map |
|---|
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values |
| Method Detail |
|---|
boolean isAllowExpired()
void setAllowExpired(boolean flag)
flag - the allow expired option.boolean isDiscardOverloaded()
void setDiscardOverloaded(boolean flag)
flag - true if new puts are discarded if overloaded, false
otherwise.boolean isAutoRefreshDeclined()
void setAutoRefreshDeclined(boolean flag)
flag - the automatic refresh declined option.int getMaxExpirationTime()
void setMaxExpirationTime(int t)
t - the secs.int getDefaultExpirationTime()
void setDefaultExpirationTime(int t)
t - the secs.int getExpirationSleepInterval()
void setExpirationSleepInterval(int t)
t - the secsint getExpirationLimit()
void setExpirationLimit(int c)
c - the expiration limit.float getExpirationThreshold()
void setExpirationThreshold(float h)
h - the threshold.
boolean add(Object key,
Object obj)
key - a key.obj - an object.
IllegalStateException - if capacity is full and overload not
allowed.
Object get(Object key,
int freq)
key - a key.freq - an expiration frequency.
Object put(Object key,
Object obj,
int freq)
key - a key.obj - an object.freq - an expiration frequency.
IllegalStateException - if capacity is full and overload not
allowed.
Object putIfAbsent(Object key,
Object obj,
int freq)
key - a key.obj - an object.freq - an expiration frequency.
IllegalStateException - if capacity is full and overload not
allowed.
boolean add(Object key,
Object obj,
int freq)
key - a key.obj - an object.freq - an expiration frequency.
IllegalStateException - if capacity is full and overload not
allowed.boolean refresh(Object key)
key - a key.
boolean refresh(Object key,
int freq)
key - a key.freq - an expiration frequency.
Object expire(Object key)
key - the key.
void expireAll()
void expireFraction(float fraction)
fraction - the fraction to expire (0.0..1.0).
IllegalArgumentException - for an invalid fragment.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||