|
JBoss API: Class TimedCachePolicy
org.jboss.util
|
Inner Class Summary | |
static interface |
TimedCachePolicy.TimedEntry
The interface that cache entries support. |
Field Summary | |
protected int |
defaultLifetime
The lifetime in seconds to use for objects inserted that do not implement the TimedEntry interface. |
protected java.util.Map |
entryMap
The map of cached TimedEntry objects. |
protected long |
now
The caches notion of the current time |
protected int |
resolution
The resolution in seconds of the cach current time |
protected static java.util.Timer |
resolutionTimer
|
protected boolean |
threadSafe
A flag indicating if entryMap should be synchronized |
Constructor Summary | |
TimedCachePolicy()
Creates a new TimedCachePolicy with a default entry lifetime of 30 mins that does not synchronized access to its policy store and uses a 60 second resolution. |
|
TimedCachePolicy(int defaultLifetime)
Creates a new TimedCachePolicy with the given default entry lifetime that does not synchronized access to its policy store and uses a 60 second resolution. |
|
TimedCachePolicy(int defaultLifetime,
boolean threadSafe,
int resolution)
Creates a new TimedCachePolicy with the given default entry lifetime that does/does not synchronized access to its policy store depending on the value of threadSafe. |
Method Summary | |
long |
currentTimeMillis()
Get the cache time. |
void |
destroy()
Clears the cache of all entries. |
void |
flush()
Remove all entries from the cache. |
java.lang.Object |
get(java.lang.Object key)
Get the cache value for key if it has not expired. |
void |
init()
Initializes the cache for use. |
void |
insert(java.lang.Object key,
java.lang.Object value)
Insert a value into the cache. |
java.lang.Object |
peek(java.lang.Object key)
Get the cache value for key. |
TimedCachePolicy.TimedEntry |
peekEntry(java.lang.Object key)
Get the raw TimedEntry for key without performing any expiration check. |
void |
remove(java.lang.Object key)
Remove the entry associated with key. |
void |
run()
The TimerTask run method. |
void |
start()
Schedules this with the class resolutionTimer Timer object for execution every resolution seconds. |
void |
stop()
Stop cancels the resolution timer and flush()es the cache. |
Methods inherited from class java.util.TimerTask |
cancel, scheduledExecutionTime |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static java.util.Timer resolutionTimer
protected java.util.Map entryMap
protected int defaultLifetime
protected boolean threadSafe
protected long now
protected int resolution
Constructor Detail |
public TimedCachePolicy()
public TimedCachePolicy(int defaultLifetime)
public TimedCachePolicy(int defaultLifetime, boolean threadSafe, int resolution)
defaultLifetime,
- the lifetime in seconds to use for objects inserted
that do not implement the TimedEntry interface.threadSafe,
- a flag indicating if the cach store should be synchronized
to allow correct operation under multi-threaded access. If true, the
cache store is synchronized. If false the cache store is unsynchronized and
the cache is not thread safe.resolution,
- the resolution in seconds of the cache timer. A cache does
not query the system time on every get() invocation. Rather the cache
updates its notion of the current time every 'resolution' seconds.Method Detail |
public void init()
public void start()
public void stop()
public void destroy()
public java.lang.Object get(java.lang.Object key)
get
in interface CachePolicy
org.jboss.util.CachePolicy
key
- the key paired with the objectCachePolicy.peek(java.lang.Object)
public java.lang.Object peek(java.lang.Object key)
peek
in interface CachePolicy
org.jboss.util.CachePolicy
key
- the key paired with the objectCachePolicy.get(java.lang.Object)
public void insert(java.lang.Object key, java.lang.Object value)
insert
in interface CachePolicy
key,
- the key for the cache entryvalue,
- Either an instance of TimedEntry that will be inserted without
change, or an abitrary value that will be wrapped in a non-refreshing
TimedEntry.public void remove(java.lang.Object key)
remove
in interface CachePolicy
org.jboss.util.CachePolicy
key
- the key paired with the objectCachePolicy.insert(java.lang.Object, java.lang.Object)
public void flush()
flush
in interface CachePolicy
public void run()
run
in class java.util.TimerTask
public long currentTimeMillis()
public TimedCachePolicy.TimedEntry peekEntry(java.lang.Object key)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |