Cocoon API: Class MemoryStore

org.apache.cocoon.store
Class MemoryStore

java.lang.Object
  |
  +--org.apache.cocoon.store.MemoryStore
All Implemented Interfaces:
Configurable, java.lang.Runnable, Status, Store

public class MemoryStore
extends java.lang.Object
implements Store, Status, Configurable, java.lang.Runnable

This class implements a memory-managed hashtable wrapper that uses a weighted mix of LRU and LFU to keep track of object importance. NOTE: this class is _HIGHLY_ un-optimized and this class is _CRITICAL_ for a fast performance of the whole system. So, if you find any better way to implement this class (clever data models, smart update algorithms, etc...), please, consider patching this implementation or sending a note about a method to do it.

Version:
$Revision: 1.15 $ $Date: 2001/01/16 22:35:01 $
Author:
Stefano Mazzocchi, Michel Lehon

Constructor Summary
MemoryStore()
           
 
Method Summary
 boolean containsKey(java.lang.Object key)
          Indicates if the given key is associated to a contained object.
 void free()
          Frees some of the fast memory used by this store.
 java.lang.Object get(java.lang.Object key)
          Get the object associated to the given unique key.
 java.lang.String getStatus()
          Returns the signature of this store implementation
 long getTime(java.lang.Object key)
          Gets the time this object was added.
 void hold(java.lang.Object key, java.lang.Object object)
          Holds the given object in a volatile state.
 void init(Configurations conf)
          Initialize the MemoryStore.
 java.util.Enumeration list()
          Returns the list of used keys.
 boolean memoryLow()
           
 void remove(java.lang.Object key)
          Remove the object associated to the given key and returns the object associated to the given key or null if not found.
 void run()
          Background memory check.
 void store(java.lang.Object key, java.lang.Object value)
          Store the given object in a persistent state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MemoryStore

public MemoryStore()
Method Detail

init

public void init(Configurations conf)
          throws InitializationException
Initialize the MemoryStore. A few options can be used :
Specified by:
init in interface Configurable

run

public void run()
Background memory check. Checks that memory is not running too low in the JVM because of the Store. It will try to keep overall memory usage below the requested levels.
Specified by:
run in interface java.lang.Runnable

memoryLow

public boolean memoryLow()

store

public void store(java.lang.Object key,
                  java.lang.Object value)
Store the given object in a persistent state. It is up to the caller to ensure that the key has a persistent state across different JVM executions.
Specified by:
store in interface Store

hold

public void hold(java.lang.Object key,
                 java.lang.Object object)
Holds the given object in a volatile state. This means the object store will discard held objects if the virtual machine is restarted or some error happens.
Specified by:
hold in interface Store

get

public java.lang.Object get(java.lang.Object key)
Get the object associated to the given unique key.
Specified by:
get in interface Store

getTime

public long getTime(java.lang.Object key)
             throws java.lang.NullPointerException
Gets the time this object was added.
Specified by:
getTime in interface Store
Throws:
java.lang.NullPointerException - if the object is not in the store.

remove

public void remove(java.lang.Object key)
Remove the object associated to the given key and returns the object associated to the given key or null if not found.
Specified by:
remove in interface Store

containsKey

public boolean containsKey(java.lang.Object key)
Indicates if the given key is associated to a contained object.
Specified by:
containsKey in interface Store

list

public java.util.Enumeration list()
Returns the list of used keys.
Specified by:
list in interface Store

free

public void free()
Frees some of the fast memory used by this store.
Specified by:
free in interface Store

getStatus

public java.lang.String getStatus()
Returns the signature of this store implementation
Specified by:
getStatus in interface Status


Copyright © 1999-2001 Apache Software Foundation. All Rights Reserved.