|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbiz.hammurapi.cache.AbstractProducer
biz.hammurapi.cache.MemoryCache
public class MemoryCache
Memory sensitive cache. Uses soft references to cache objects.
Field Summary | |
---|---|
protected java.util.Map |
cache
|
static long |
CLEANUP_INTERVAL
Default cache cleanup interval. |
protected Producer |
producer
|
protected java.util.Map |
reverseCache
|
Constructor Summary | |
---|---|
MemoryCache(Producer producer,
Cache fallBack,
MeasurementCategory measurementCategory)
Constructs cache with default cleanup interval (1 minute). |
|
MemoryCache(Producer producer,
Cache fallBack,
MeasurementCategory measurementCategory,
java.util.Timer timer,
long cleanupInterval)
Constructs cache with default cleanup interval (1 minute). |
Method Summary | |
---|---|
void |
clear()
Removes all cache entries |
protected void |
finalize()
|
Entry |
get(java.lang.Object key)
|
boolean |
isActive()
|
java.util.Set |
keySet()
|
void |
put(java.lang.Object key,
java.lang.Object value,
long time,
long expirationTime)
Puts entry to cache |
void |
remove(Acceptor acceptor)
Removes keys accepted by acceptor |
void |
remove(java.lang.Object key)
Removes entry with specified key |
void |
setOwner(java.lang.Object owner)
Plugs the component into container and naming bus. |
void |
start()
Creates timer if neccessary, creates cleanup task and schedules it. |
void |
stop()
Invoked by container when component is not needed anymore. |
Methods inherited from class biz.hammurapi.cache.AbstractProducer |
---|
addCache, onRemove |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface biz.hammurapi.cache.Producer |
---|
addCache |
Field Detail |
---|
protected java.util.Map cache
protected java.util.Map reverseCache
protected Producer producer
public static final long CLEANUP_INTERVAL
Constructor Detail |
---|
public MemoryCache(Producer producer, Cache fallBack, MeasurementCategory measurementCategory)
producer
- ProducerfallBack
- Fallback cachemeasurementCategory
- Measurement category to report cache statisticspublic MemoryCache(Producer producer, Cache fallBack, MeasurementCategory measurementCategory, java.util.Timer timer, long cleanupInterval)
producer
- ProducerfallBack
- Fallback cachemeasurementCategory
- Measurement category to report cache statisticscleanupInterval
- Interval between removals of expired entries.timer
- Timer which will invoke cleanup tasks, if it is null then a new timer is created internally.
Use this parameter to share timers between multiple caches in order to reduce number of threads in the
application.Method Detail |
---|
public void put(java.lang.Object key, java.lang.Object value, long time, long expirationTime)
Cache
put
in interface Cache
key
- Keyvalue
- Valuetime
- Timestamp (last modified)expirationTime
- Expiration timepublic Entry get(java.lang.Object key)
get
in interface Producer
public void clear()
Cache
clear
in interface Cache
public void remove(java.lang.Object key)
Cache
remove
in interface Cache
public void remove(Acceptor acceptor)
Cache
remove
in interface Cache
public void stop()
Component
stop
in interface Component
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
public java.util.Set keySet()
keySet
in interface Producer
public boolean isActive()
isActive
in interface Cache
public void start() throws ConfigurationException
start
in interface Component
ConfigurationException
public void setOwner(java.lang.Object owner)
Component
setOwner
in interface Component
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |