|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.norther.tammi.acorn.cache.CachedMapAdapter
public class CachedMapAdapter
Extends the given ConcurrentMap implementation to support the
CachedMap interface.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface java.util.Map |
|---|
Map.Entry<K,V> |
| Field Summary | |
|---|---|
static int |
DEFAULT_EXPIRATION_SLEEP_INTERVAL
The default expiration sleep interval. |
static int |
DEFAULT_EXPIRATION_TIME
The default expiration time. |
| Constructor Summary | |
|---|---|
CachedMapAdapter(ConcurrentMap m)
Constructs a new map. |
|
CachedMapAdapter(ConcurrentMap m,
int max)
Constructs a new map with a max expiration time. |
|
CachedMapAdapter(ConcurrentMap m,
int max,
int def)
Constructs a new map with max and default expiration times. |
|
CachedMapAdapter(ConcurrentMap m,
int max,
int def,
int sleep)
Constructs a new map with max and default expiration times and an expiration sleep interval. |
|
| 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. |
void |
clear()
|
boolean |
containsKey(Object key)
|
boolean |
containsValue(Object obj)
|
Set |
entrySet()
|
boolean |
equals(Object object)
|
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)
|
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. |
ScheduledTimer |
getExpirationTimer()
Gets the expiration timer. |
int |
getMaxExpirationTime()
Gets the maximum expiration time in seconds. |
CacheListener |
getSwapOutHandler()
Gets the swap out handler. |
int |
hashCode()
|
boolean |
isAllowExpired()
Gets the allow expired option. |
boolean |
isAutoRefreshDeclined()
Gets the automatic refresh declined option. |
boolean |
isDiscardOverloaded()
Gets the discard overloaded option. |
boolean |
isEmpty()
|
Set |
keySet()
|
Object |
put(Object key,
Object obj)
|
Object |
put(Object key,
Object obj,
int freq)
Puts a cachable object into the map with an object specific expiration frequency. |
void |
putAll(Map map)
|
Object |
putIfAbsent(Object key,
Object obj)
|
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. |
Object |
remove(Object key)
|
boolean |
remove(Object key,
Object obj)
|
Object |
replace(Object key,
Object obj)
|
boolean |
replace(Object key,
Object old,
Object obj)
|
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 |
setExpirationTimer(ScheduledTimer t)
Sets the expiration timer. |
void |
setMaxExpirationTime(int t)
Sets the maximum expiration time in seconds. |
void |
setSwapOutHandler(CacheListener handler)
Sets the swap out handler. |
int |
size()
|
String |
toString()
|
Collection |
values()
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int DEFAULT_EXPIRATION_TIME
public static final int DEFAULT_EXPIRATION_SLEEP_INTERVAL
| Constructor Detail |
|---|
public CachedMapAdapter(ConcurrentMap m)
m - the wrapped map.
public CachedMapAdapter(ConcurrentMap m,
int max)
m - the wrapped map.max - a max expiration time (0 = default, -1 = infinite).
public CachedMapAdapter(ConcurrentMap m,
int max,
int def)
m - the wrapped map.max - a max expiration time (0 = default, -1 = infinite).def - a default expiration time (0 = default, -1 = infinite).
public CachedMapAdapter(ConcurrentMap m,
int max,
int def,
int sleep)
m - the wrapped map.max - a max expiration time (0 = default, -1 = infinite).def - a default expiration time (0 = default, -1 = infinite).sleep - an expiration sleep interval (0 = default, -1 = infinite).| Method Detail |
|---|
public ScheduledTimer getExpirationTimer()
public void setExpirationTimer(ScheduledTimer t)
Note that the specified timer does not remain over serialization but the default timer is applied if not reset.
t - the timer.public CacheListener getSwapOutHandler()
public void setSwapOutHandler(CacheListener handler)
handler - the swap out handler.public boolean isAllowExpired()
CachedMap
isAllowExpired in interface CachedMappublic void setAllowExpired(boolean flag)
CachedMap
setAllowExpired in interface CachedMapflag - the allow expired option.public boolean isDiscardOverloaded()
CachedMap
isDiscardOverloaded in interface CachedMappublic void setDiscardOverloaded(boolean flag)
CachedMap
setDiscardOverloaded in interface CachedMapflag - true if new puts are discarded if overloaded, false
otherwise.public boolean isAutoRefreshDeclined()
CachedMap
isAutoRefreshDeclined in interface CachedMappublic void setAutoRefreshDeclined(boolean flag)
CachedMap
setAutoRefreshDeclined in interface CachedMapflag - the automatic refresh declined option.public int getMaxExpirationTime()
CachedMap
getMaxExpirationTime in interface CachedMappublic void setMaxExpirationTime(int t)
CachedMap
setMaxExpirationTime in interface CachedMapt - the secs.public int getDefaultExpirationTime()
CachedMap
getDefaultExpirationTime in interface CachedMappublic void setDefaultExpirationTime(int t)
CachedMap
setDefaultExpirationTime in interface CachedMapt - the secs.public int getExpirationSleepInterval()
CachedMap
getExpirationSleepInterval in interface CachedMappublic void setExpirationSleepInterval(int t)
CachedMap
setExpirationSleepInterval in interface CachedMapt - the secspublic int getExpirationLimit()
CachedMap
getExpirationLimit in interface CachedMappublic void setExpirationLimit(int c)
CachedMap
setExpirationLimit in interface CachedMapc - the expiration limit.public float getExpirationThreshold()
CachedMap
getExpirationThreshold in interface CachedMappublic void setExpirationThreshold(float h)
CachedMap
setExpirationThreshold in interface CachedMaph - the threshold.public boolean equals(Object object)
equals in interface Mapequals in class Objectpublic int hashCode()
hashCode in interface MaphashCode in class Objectpublic String toString()
toString in class Objectpublic void clear()
clear in interface Mappublic boolean containsKey(Object key)
containsKey in interface Mappublic boolean containsValue(Object obj)
containsValue in interface Mappublic Set entrySet()
entrySet in interface Mappublic Object get(Object key)
get in interface Mappublic Set keySet()
keySet in interface Map
public Object put(Object key,
Object obj)
put in interface Map
public Object putIfAbsent(Object key,
Object obj)
putIfAbsent in interface ConcurrentMap
public boolean add(Object key,
Object obj)
CachedMap
add in interface CachedMapkey - a key.obj - an object.
public Object replace(Object key,
Object obj)
replace in interface ConcurrentMap
public boolean replace(Object key,
Object old,
Object obj)
replace in interface ConcurrentMappublic void putAll(Map map)
putAll in interface Mappublic Object remove(Object key)
remove in interface Map
public boolean remove(Object key,
Object obj)
remove in interface ConcurrentMappublic int size()
size in interface Mappublic boolean isEmpty()
isEmpty in interface Mappublic Collection values()
values in interface Map
public Object get(Object key,
int freq)
CachedMap
get in interface CachedMapkey - a key.freq - an expiration frequency.
public Object put(Object key,
Object obj,
int freq)
CachedMap
put in interface CachedMapkey - a key.obj - an object.freq - an expiration frequency.
public Object putIfAbsent(Object key,
Object obj,
int freq)
CachedMap
putIfAbsent in interface CachedMapkey - a key.obj - an object.freq - an expiration frequency.
public boolean add(Object key,
Object obj,
int freq)
CachedMap
add in interface CachedMapkey - a key.obj - an object.freq - an expiration frequency.
public boolean refresh(Object key)
CachedMap
refresh in interface CachedMapkey - a key.
public boolean refresh(Object key,
int freq)
CachedMap
refresh in interface CachedMapkey - a key.freq - an expiration frequency.
public Object expire(Object key)
CachedMap
expire in interface CachedMapkey - the key.
public void expireAll()
CachedMap
expireAll in interface CachedMappublic void expireFraction(float fraction)
CachedMap
expireFraction in interface CachedMapfraction - the fraction to expire (0.0..1.0).
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||