org.activemq.io.util
Class MemoryBoundedMessageCache

java.lang.Object
  extended byorg.activemq.io.util.MemoryBoundedMessageCache
All Implemented Interfaces:
MemoryBoundedObject, MessageCache

public class MemoryBoundedMessageCache
extends Object
implements MessageCache, MemoryBoundedObject

A simple cache that stores messages in memory. Cache entries are evicted when the memoryManager starts to run short on memory (A LRU cache is used).

Version:
$Revision: 1.1.1.1 $

Constructor Summary
MemoryBoundedMessageCache(MemoryBoundedObjectManager memoryManager)
           
 
Method Summary
 void close()
          Lets a cache know it will not be used any further and that it can release aquired resources
 ActiveMQMessage get(String msgid)
          Gets a message that was previously put into this object.
 float getGrowthLimit()
           
 void put(String messageID, ActiveMQMessage message)
          Puts a message into the cache.
 void remove(String messageID)
          Remvoes a message from the cache.
 void setGrowthLimit(float growTillFence)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MemoryBoundedMessageCache

public MemoryBoundedMessageCache(MemoryBoundedObjectManager memoryManager)
Method Detail

get

public ActiveMQMessage get(String msgid)
Gets a message that was previously put into this object.

Specified by:
get in interface MessageCache
Parameters:
msgid -
Returns:
null if the message was not previously put or if the message has expired out of the cache.

put

public void put(String messageID,
                ActiveMQMessage message)
Puts a message into the cache.

Specified by:
put in interface MessageCache
Parameters:
messageID -
message -

remove

public void remove(String messageID)
Remvoes a message from the cache.

Specified by:
remove in interface MessageCache
Parameters:
messageID -

getGrowthLimit

public float getGrowthLimit()
Returns:
returns the percentage of memory usage at which that cache will stop to grow.

setGrowthLimit

public void setGrowthLimit(float growTillFence)
Parameters:
growTillFence - the percentage of memory usage at which that cache will stop to grow.

close

public void close()
Description copied from interface: MessageCache
Lets a cache know it will not be used any further and that it can release aquired resources

Specified by:
close in interface MessageCache


Copyright © 2004-2007 Protique, Ltd.. All Rights Reserved.