org.apache.portals.applications.transform.impl
Class MemoryTransformCache

java.lang.Object
  extended by org.apache.portals.applications.transform.impl.MemoryTransformCache
All Implemented Interfaces:
java.util.Comparator, java.util.Observer, TransformCache

public class MemoryTransformCache
extends java.lang.Object
implements TransformCache

TransformCacheComponent

Version:
$Id: MemoryTransformCache.java 517719 2007-03-13 15:05:48Z ate $
Author:
David Sean Taylor

Constructor Summary
MemoryTransformCache(Transform transform, int maxSize, int evictionPercentage, boolean enable, boolean debug)
          Spring constructor injection
 
Method Summary
 void clearCache()
          Clear the Transform Cache
 int compare(java.lang.Object o1, java.lang.Object o2)
           
 java.lang.String constructKey(java.lang.String url, java.lang.String stylesheet)
          Construct the key for the TransformDocumentTreeMap cache
protected  void evict()
          The eviction policy will keep n items in the cache, and then start evicting x items ordered-by least used first.
 TransformCacheEntry get(java.lang.String key)
          Retrieve the unique TransformCacheEntry keyed off with key
 java.lang.Object getDocument(java.lang.String key)
          Retrieve the byte[] storing the transformed content for the transfomId and the documentId combination.
 int getEvictionPercentage()
          Get the eviction percentage of the cache
 int getMaxSize()
          Get the maximum size of the cache
 boolean isEnabled()
          Find out if TransformCache is enables
 void put(java.lang.String key, java.lang.Object document, long timeToLive)
          Put a value in the TransformCache keyed off with the TransformId and the DocumentId.
 java.lang.Object remove(java.lang.String key)
          Remove a unique value keyed off with the TransformId and DocumentId from the cache.
 void setMaxSize(int maxSize)
          Set the new maximum size of the cache
 void update(java.util.Observable o, java.lang.Object arg)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

MemoryTransformCache

public MemoryTransformCache(Transform transform,
                            int maxSize,
                            int evictionPercentage,
                            boolean enable,
                            boolean debug)
Spring constructor injection

Method Detail

getMaxSize

public int getMaxSize()
Description copied from interface: TransformCache
Get the maximum size of the cache

Specified by:
getMaxSize in interface TransformCache
Returns:
the current maximum size of the cache

setMaxSize

public void setMaxSize(int maxSize)
Description copied from interface: TransformCache
Set the new maximum size of the cache

Specified by:
setMaxSize in interface TransformCache
Parameters:
maxSize - the maximum size of the cache

getEvictionPercentage

public int getEvictionPercentage()
Description copied from interface: TransformCache
Get the eviction percentage of the cache

Specified by:
getEvictionPercentage in interface TransformCache
Returns:
the eviction percentage of the cache

isEnabled

public boolean isEnabled()
Description copied from interface: TransformCache
Find out if TransformCache is enables

Specified by:
isEnabled in interface TransformCache
Returns:
the enable flag of the cache

put

public void put(java.lang.String key,
                java.lang.Object document,
                long timeToLive)
Description copied from interface: TransformCache
Put a value in the TransformCache keyed off with the TransformId and the DocumentId.

Specified by:
put in interface TransformCache

evict

protected void evict()
The eviction policy will keep n items in the cache, and then start evicting x items ordered-by least used first. n = max size of cache x = (eviction_percentage/100) * n


remove

public java.lang.Object remove(java.lang.String key)
Description copied from interface: TransformCache
Remove a unique value keyed off with the TransformId and DocumentId from the cache.

Specified by:
remove in interface TransformCache
Returns:
Object

get

public TransformCacheEntry get(java.lang.String key)
Description copied from interface: TransformCache
Retrieve the unique TransformCacheEntry keyed off with key

Specified by:
get in interface TransformCache
Returns:
TransformCacheEntry

getDocument

public java.lang.Object getDocument(java.lang.String key)
Description copied from interface: TransformCache
Retrieve the byte[] storing the transformed content for the transfomId and the documentId combination.

Specified by:
getDocument in interface TransformCache
Returns:
Object

compare

public int compare(java.lang.Object o1,
                   java.lang.Object o2)
Specified by:
compare in interface java.util.Comparator

constructKey

public java.lang.String constructKey(java.lang.String url,
                                     java.lang.String stylesheet)
Description copied from interface: TransformCache
Construct the key for the TransformDocumentTreeMap cache

Specified by:
constructKey in interface TransformCache
Returns:
String

clearCache

public void clearCache()
Description copied from interface: TransformCache
Clear the Transform Cache

Specified by:
clearCache in interface TransformCache

update

public void update(java.util.Observable o,
                   java.lang.Object arg)
Specified by:
update in interface java.util.Observer


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