Dashboard Builder Commons 6.0.0.Beta1

org.jboss.dashboard.database.cache.custom
Class TimerCache

java.lang.Object
  extended by org.jboss.dashboard.database.cache.custom.TimerCache
All Implemented Interfaces:
Runnable, ObjectCache, StatisticsObjectCache

public class TimerCache
extends Object
implements StatisticsObjectCache, Runnable

Cache implementation that times out cached elements. Each item put in the cache is timed out after a specified number of milliseconds (unless removed before the timeout).


Constructor Summary
TimerCache(boolean monitorizeCaches, long timeout, int size)
           
 
Method Summary
 Object clear(Serializable key)
          Clears an object from the cache by key.
 void clearAll()
          Clears the entire cache.
 Object get(Serializable key)
          Gets an object from the cache by key, or returns null if that object is not cached.
 CacheStatistics getCacheStatistics()
          Get the cache statistics
 String getType()
          Gets the cache type name.
 void put(Serializable key, Object object)
          Caches an object.
 void run()
           
protected  void setDeadline(long time)
           
 void setTimeout(long newTimeout)
          Sets a new timeout value-- only do this before using the cache!
 void setType(String type)
          Sets the cache type name.
 void stop()
          Called to stop the timer thread.
protected  void trimQueue(SynchronizedLRUMap cache)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimerCache

public TimerCache(boolean monitorizeCaches,
                  long timeout,
                  int size)
Method Detail

setTimeout

public void setTimeout(long newTimeout)
Sets a new timeout value-- only do this before using the cache!


stop

public void stop()
Called to stop the timer thread. This should only be called once and the cache should not be used afterwards.


getType

public String getType()
Gets the cache type name.

Specified by:
getType in interface ObjectCache

setType

public void setType(String type)
Sets the cache type name.

Specified by:
setType in interface ObjectCache

put

public void put(Serializable key,
                Object object)
Caches an object. If object is null, then any object cached at the given key is removed from the cache.

Specified by:
put in interface ObjectCache

get

public Object get(Serializable key)
Description copied from interface: ObjectCache
Gets an object from the cache by key, or returns null if that object is not cached.

Specified by:
get in interface ObjectCache

clear

public Object clear(Serializable key)
Description copied from interface: ObjectCache
Clears an object from the cache by key.

Specified by:
clear in interface ObjectCache

clearAll

public void clearAll()
Description copied from interface: ObjectCache
Clears the entire cache.

Specified by:
clearAll in interface ObjectCache

setDeadline

protected void setDeadline(long time)

run

public void run()
Specified by:
run in interface Runnable

trimQueue

protected void trimQueue(SynchronizedLRUMap cache)

getCacheStatistics

public CacheStatistics getCacheStatistics()
Description copied from interface: StatisticsObjectCache
Get the cache statistics

Specified by:
getCacheStatistics in interface StatisticsObjectCache
Returns:
the cache statistics

Dashboard Builder Commons 6.0.0.Beta1

Copyright © 2012-2013 JBoss by Red Hat. All Rights Reserved.