|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.norther.tammi.acorn.cache.CachedMapAdapter<K,V>
K
- the type of keys maintained by this map.V
- the type of mapped values.public class CachedMapAdapter<K,V>
Extends the given ConcurrentMap
implementation to support the
CachedMap interface.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.norther.tammi.acorn.cache.CachedMap |
---|
CachedMap.Value<K,V> |
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<K,CachedMap.Value<K,V>> m)
Constructs a new map. |
|
CachedMapAdapter(ConcurrentMap<K,CachedMap.Value<K,V>> m,
int max)
Constructs a new map with a max expiration time. |
|
CachedMapAdapter(ConcurrentMap<K,CachedMap.Value<K,V>> m,
int max,
int def)
Constructs a new map with max and default expiration times. |
|
CachedMapAdapter(ConcurrentMap<K,CachedMap.Value<K,V>> 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(K key,
V obj)
Adds a cachable object into the map but only if the specified key is not already mapped. |
boolean |
add(K key,
V 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<Map.Entry<K,V>> |
entrySet()
|
boolean |
equals(Object object)
|
V |
expire(Object key)
Expires and removes an entry. |
void |
expireAll()
Expires all entries. |
void |
expireFraction(float fraction)
Expires a fraction of entries. |
V |
get(Object key)
|
V |
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<K> |
keySet()
|
V |
put(K key,
V obj)
|
V |
put(K key,
V obj,
int freq)
Puts a cachable object into the map with an object specific expiration frequency. |
void |
putAll(Map<? extends K,? extends V> map)
|
V |
putIfAbsent(K key,
V obj)
|
V |
putIfAbsent(K key,
V 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. |
V |
remove(Object key)
|
boolean |
remove(Object key,
Object obj)
|
V |
replace(K key,
V obj)
|
boolean |
replace(K key,
V old,
V 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<V> |
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<K,CachedMap.Value<K,V>> m)
m
- the wrapped map.public CachedMapAdapter(ConcurrentMap<K,CachedMap.Value<K,V>> m, int max)
m
- the wrapped map.max
- a max expiration time (0 = default, -1 = infinite).public CachedMapAdapter(ConcurrentMap<K,CachedMap.Value<K,V>> 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<K,CachedMap.Value<K,V>> 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 CachedMap<K,V>
public void setAllowExpired(boolean flag)
CachedMap
setAllowExpired
in interface CachedMap<K,V>
flag
- the allow expired option.public boolean isDiscardOverloaded()
CachedMap
isDiscardOverloaded
in interface CachedMap<K,V>
public void setDiscardOverloaded(boolean flag)
CachedMap
setDiscardOverloaded
in interface CachedMap<K,V>
flag
- true if new puts are discarded if overloaded, false
otherwise.public boolean isAutoRefreshDeclined()
CachedMap
isAutoRefreshDeclined
in interface CachedMap<K,V>
public void setAutoRefreshDeclined(boolean flag)
CachedMap
setAutoRefreshDeclined
in interface CachedMap<K,V>
flag
- the automatic refresh declined option.public int getMaxExpirationTime()
CachedMap
getMaxExpirationTime
in interface CachedMap<K,V>
public void setMaxExpirationTime(int t)
CachedMap
setMaxExpirationTime
in interface CachedMap<K,V>
t
- the secs.public int getDefaultExpirationTime()
CachedMap
getDefaultExpirationTime
in interface CachedMap<K,V>
public void setDefaultExpirationTime(int t)
CachedMap
setDefaultExpirationTime
in interface CachedMap<K,V>
t
- the secs.public int getExpirationSleepInterval()
CachedMap
getExpirationSleepInterval
in interface CachedMap<K,V>
public void setExpirationSleepInterval(int t)
CachedMap
setExpirationSleepInterval
in interface CachedMap<K,V>
t
- the secspublic int getExpirationLimit()
CachedMap
getExpirationLimit
in interface CachedMap<K,V>
public void setExpirationLimit(int c)
CachedMap
setExpirationLimit
in interface CachedMap<K,V>
c
- the expiration limit.public float getExpirationThreshold()
CachedMap
getExpirationThreshold
in interface CachedMap<K,V>
public void setExpirationThreshold(float h)
CachedMap
setExpirationThreshold
in interface CachedMap<K,V>
h
- the threshold.public boolean equals(Object object)
equals
in interface Map<K,V>
equals
in class Object
public int hashCode()
hashCode
in interface Map<K,V>
hashCode
in class Object
public String toString()
toString
in class Object
public void clear()
clear
in interface Map<K,V>
public boolean containsKey(Object key)
containsKey
in interface Map<K,V>
public boolean containsValue(Object obj)
containsValue
in interface Map<K,V>
public Set<Map.Entry<K,V>> entrySet()
entrySet
in interface Map<K,V>
public V get(Object key)
get
in interface Map<K,V>
public Set<K> keySet()
keySet
in interface Map<K,V>
public V put(K key, V obj)
put
in interface Map<K,V>
public V putIfAbsent(K key, V obj)
putIfAbsent
in interface ConcurrentMap<K,V>
public boolean add(K key, V obj)
CachedMap
add
in interface CachedMap<K,V>
key
- a key.obj
- an object.
public V replace(K key, V obj)
replace
in interface ConcurrentMap<K,V>
public boolean replace(K key, V old, V obj)
replace
in interface ConcurrentMap<K,V>
public void putAll(Map<? extends K,? extends V> map)
putAll
in interface Map<K,V>
public V remove(Object key)
remove
in interface Map<K,V>
public boolean remove(Object key, Object obj)
remove
in interface ConcurrentMap<K,V>
public int size()
size
in interface Map<K,V>
public boolean isEmpty()
isEmpty
in interface Map<K,V>
public Collection<V> values()
values
in interface Map<K,V>
public V get(Object key, int freq)
CachedMap
get
in interface CachedMap<K,V>
key
- a key.freq
- an expiration frequency.
public V put(K key, V obj, int freq)
CachedMap
put
in interface CachedMap<K,V>
key
- a key.obj
- an object.freq
- an expiration frequency.
public V putIfAbsent(K key, V obj, int freq)
CachedMap
putIfAbsent
in interface CachedMap<K,V>
key
- a key.obj
- an object.freq
- an expiration frequency.
public boolean add(K key, V obj, int freq)
CachedMap
add
in interface CachedMap<K,V>
key
- a key.obj
- an object.freq
- an expiration frequency.
public boolean refresh(Object key)
CachedMap
refresh
in interface CachedMap<K,V>
key
- a key.
public boolean refresh(Object key, int freq)
CachedMap
refresh
in interface CachedMap<K,V>
key
- a key.freq
- an expiration frequency.
public V expire(Object key)
CachedMap
expire
in interface CachedMap<K,V>
key
- the key.
public void expireAll()
CachedMap
expireAll
in interface CachedMap<K,V>
public void expireFraction(float fraction)
CachedMap
expireFraction
in interface CachedMap<K,V>
fraction
- the fraction to expire (0.0..1.0).
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |